> For the complete documentation index, see [llms.txt](https://cultura-1.gitbook.io/cultura/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cultura-1.gitbook.io/cultura/undefined/usage.md).

# Usage

#### Running Cultura.js

Start by creating a Cultura client that interacts with Deepseek’s API.

**Example Code**

```javascript
javascriptCopyconst { Cultura } = require('deepseek-cultura-node');

const client = new Cultura(process.env.DEEPSEEK_API_KEY);
client.run();
```

The `run()` function in Cultura.js is similar to Deepseek's `chat.completions.create()` function but with additional features like agent function execution, handoffs, context variables, and multi-turn conversations.

**Arguments**

**Response Fields**

#### Agents

An Agent encapsulates instructions and functions (tools). These agents drive the conversation and can decide whether to hand off to another agent.

**Example Code**

```javascript
javascriptCopyconst agentA = new Agent({
  name: "Agent A",
  instructions: "You are a helpful agent.",
});
```

#### Functions

Functions enable agents to perform actions like processing transactions, looking up information, or transferring control to other agents. Functions are called when the agent needs to perform a specific task.

**Example Code**

```javascript
javascriptCopyconst transferToAgentB = () => agentB;

const agentA = new Agent({
  name: "Agent A",
  instructions: "You are a helpful agent.",
  tools: [{ name: 'transferToAgentB', fn: transferToAgentB }],
});
```

#### Handoffs and Context Variables

Agents can transfer control to other agents or update `contextVariables` based on the conversation flow.

**Example Code**

```javascript
javascriptCopyconst salesAgent = new Agent({ name: "Sales Agent" });

const agent = new Agent({
  functions: [
    () => new Result({ agent: salesAgent, contextVariables: { department: "sales" } }),
  ],
});
```

#### Function Schemas

Cultura.js automatically converts functions into JSON schemas, allowing Deepseek’s API to call the appropriate function based on the tool name.

**Example Code**

```javascript
javascriptCopyfunction lookUpItem(searchQuery) {
    /**
     * @description Use to find item ID. Search query can be a description or keywords.
     * @param {string} searchQuery - Description or keywords to search for the item.
     * @returns {string} - The found item ID.
     */

    return console.log(`Searching for item: ${searchQuery}`);
}
```

#### Streaming

You can enable streaming in Cultura.js to receive real-time responses from agents.

**Example Code**

```javascript
javascriptCopyconst stream = client.run({ agent, messages, stream: true });
for await (const chunk of stream) {
    console.log(chunk);
}
```

#### Evaluations

Cultura.js supports various evaluation methods to test and validate your multi-agent systems. You can find example evaluations in the `/examples` directory.

#### Utils

Use the `run_demo_loop` utility to test your agents interactively in a REPL environment.

**Example Code**

```javascript
javascriptCopyconst { run_demo_loop } = require('deepseek-cultura-node/utils');

run_demo_loop(agent);
```

#### Core Contributors

* **Pulkit Garg** (Node.js adaptation)
* **Deepseek** (original Python framework)

This README now emphasizes that Cultura.js is a Node.js implementation of Deepseek, while maintaining a high standard for documentation and usage clarity.
