-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
67 lines (63 loc) · 2.54 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import Groq from 'groq-sdk';
import { AgentType, Agent } from './core/agents';
import {ToolUseModels} from "./core/types"
import {DependencyType} from "./agents/agentBody"
export class GroqAgent {
/**
* specific groq hosted model to use, the model must support tool use
*/
public model: ToolUseModels
private api_key: string;
private GroqClient: Groq;
constructor(api_key: string, model: ToolUseModels) {
this.api_key = api_key;
this.model = model;
this.GroqClient = new Groq({ apiKey: this.api_key });
}
/**
* This method lists all the available agents and their agent id. Select a specific agent by calling the `agent` method and with the agent's id as a parameter
* @returns an array of agents data
* @example `{
* agent_name: string,
* agent_id: string,
* description: string
* }[]`
*/
public agents() {
const groq_client = this.GroqClient;
console.log([
{
agent_name: "X Agent",
agent_id: "101",
description: "Agent that interfaces with the X social media platform"
}
]);
// should return {agent_name: string, agent_id: string, description: string}[]
}
/**
* @returns an array of tool calling models that are available to power any agent
*/
public models() {
return ["llama-3.3-70b-versatile", "llama-3.1-8b-instant", "llama3-70b-8192", "llama3-8b-8192"] as ToolUseModels[];
}
/**
* Method to create an Agent instance and interact with it
* @param system Optional system message to initialize the agent
* @param agentBody Optional, the raw code that defines an agent. Of type `AgentType`
* @param task String that defines the task the agent is to accomplish
* @param timer Number that defines the max amount of time (in milliseconds) the agent should spend on a task. Default of 1 min
* @returns an instance of the Agent class
*/
public create( task:string, system?: string, agentBody?: AgentType, timer?: number):Agent {
return new Agent(system, agentBody, this.model, task, this.api_key, timer);
}
public installDependencies(dependencies:DependencyType){}
}
async function main(){
const agentClient = new GroqAgent(`api_key`, 'llama-3.3-70b-versatile')
const agent = agentClient.create("Find an agent that can interact with the twitter/X platform")
const response = agent.work()
console.log("Agent Response:", response)
}
main()
export default GroqAgent;