Skip to content

Commit 1648a14

Browse files
authored
Merge pull request #1 from automaze1/main
Tools enhancement and Agents implementation
2 parents 819688d + 3187420 commit 1648a14

File tree

56 files changed

+2874
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2874
-125
lines changed

build/GenerativeAI.zip

13 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
# Agent
2+
3+
Namespace: Automation.GenerativeAI.Agents
4+
5+
Represents an Agent that can perform certain actions to accomplish given objective.
6+
7+
```csharp
8+
public abstract class Agent
9+
```
10+
11+
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Agent](./automation.generativeai.agents.agent.md)
12+
13+
## Properties
14+
15+
### **Name**
16+
17+
Name of the Agent
18+
19+
```csharp
20+
public string Name { get; private set; }
21+
```
22+
23+
#### Property Value
24+
25+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
26+
27+
### **Description**
28+
29+
Description of the agent
30+
31+
```csharp
32+
public string Description { get; set; }
33+
```
34+
35+
#### Property Value
36+
37+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
38+
39+
## Methods
40+
41+
### **WithDescription(String)**
42+
43+
Sets description
44+
45+
```csharp
46+
public Agent WithDescription(string description)
47+
```
48+
49+
#### Parameters
50+
51+
`description` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
52+
Description of the agent.
53+
54+
#### Returns
55+
56+
[Agent](./automation.generativeai.agents.agent.md)<br>
57+
This Agent
58+
59+
### **WithTools(IEnumerable&lt;IFunctionTool&gt;)**
60+
61+
Sets a list of allowed tools for agent to use.
62+
63+
```csharp
64+
public Agent WithTools(IEnumerable<IFunctionTool> tools)
65+
```
66+
67+
#### Parameters
68+
69+
`tools` [IEnumerable&lt;IFunctionTool&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)<br>
70+
List of tools
71+
72+
#### Returns
73+
74+
[Agent](./automation.generativeai.agents.agent.md)<br>
75+
This Agent
76+
77+
### **WithLanguageModel(ILanguageModel)**
78+
79+
Sets language model to the agent
80+
81+
```csharp
82+
public Agent WithLanguageModel(ILanguageModel languageModel)
83+
```
84+
85+
#### Parameters
86+
87+
`languageModel` [ILanguageModel](./automation.generativeai.interfaces.ilanguagemodel.md)<br>
88+
Language model for agent to perform certain tasks
89+
90+
#### Returns
91+
92+
[Agent](./automation.generativeai.agents.agent.md)<br>
93+
This Agent
94+
95+
### **WithTemperature(Double)**
96+
97+
Sets the temperature parameter to agent to define the creativity.
98+
99+
```csharp
100+
public Agent WithTemperature(double temperature)
101+
```
102+
103+
#### Parameters
104+
105+
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
106+
A value between 0 and 1 to define creativity
107+
108+
#### Returns
109+
110+
[Agent](./automation.generativeai.agents.agent.md)<br>
111+
This Agent
112+
113+
### **WithMaxAllowedSteps(Int32)**
114+
115+
Sets the maximum number of steps this agent can execute.
116+
117+
```csharp
118+
public Agent WithMaxAllowedSteps(int maxAllowedSteps)
119+
```
120+
121+
#### Parameters
122+
123+
`maxAllowedSteps` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
124+
Maximum number of steps that can be executed.
125+
126+
#### Returns
127+
128+
[Agent](./automation.generativeai.agents.agent.md)<br>
129+
This Agent
130+
131+
### **GetNextActionAsync(List&lt;ChatMessage&gt;)**
132+
133+
Provides a next agent action based on the given message history.
134+
135+
```csharp
136+
protected abstract Task<AgentAction> GetNextActionAsync(List<ChatMessage> messages)
137+
```
138+
139+
#### Parameters
140+
141+
`messages` [List&lt;ChatMessage&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)<br>
142+
History of messages as a list
143+
144+
#### Returns
145+
146+
[Task&lt;AgentAction&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)<br>
147+
AgentAction
148+
149+
### **ExecuteAsync(String)**
150+
151+
Executes the given objective
152+
153+
```csharp
154+
public Task<AgentAction> ExecuteAsync(string objective)
155+
```
156+
157+
#### Parameters
158+
159+
`objective` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
160+
The detailed objective for agent to achieve.
161+
162+
#### Returns
163+
164+
[Task&lt;AgentAction&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)<br>
165+
FinishAction if objective is met or got an error. It may return AgentAction if the
166+
tool associated with the action can't be executed. It provides clients to execute the
167+
action logic and then call UpdateToolResponseAsync to proceed further with execution.
168+
169+
### **UpdateAgentActionResponseAsync(String, String)**
170+
171+
Called by the client to update the tool's execution result with the agent, if the tool
172+
corresponding to the agent action was executed by client.
173+
174+
```csharp
175+
public Task<AgentAction> UpdateAgentActionResponseAsync(string toolName, string output)
176+
```
177+
178+
#### Parameters
179+
180+
`toolName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
181+
Name of the tool that executed
182+
183+
`output` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
184+
Output of the tool.
185+
186+
#### Returns
187+
188+
[Task&lt;AgentAction&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)<br>
189+
FinishAction if objective is met or got an error. AgentAction if it is
190+
required to be executed by client.
191+
192+
### **LoadSystemPrompt(String, String, String)**
193+
194+
The derived class implements this method to provide a system prompt text for the language model.
195+
196+
```csharp
197+
protected abstract string LoadSystemPrompt(string username, string date, string workingdir)
198+
```
199+
200+
#### Parameters
201+
202+
`username` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
203+
Name of the user interactive with agent
204+
205+
`date` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
206+
Today's date
207+
208+
`workingdir` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
209+
Full path of the working directory
210+
211+
#### Returns
212+
213+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
214+
System prompt text
215+
216+
### **Create(String, String, AgentType)**
217+
218+
Creates an agent
219+
220+
```csharp
221+
public static Agent Create(string name, string workingdir, AgentType type)
222+
```
223+
224+
#### Parameters
225+
226+
`name` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
227+
A unique name of the agent
228+
229+
`workingdir` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
230+
Full path of the working directory
231+
232+
`type` [AgentType](./automation.generativeai.agents.agenttype.md)<br>
233+
Type of the agent to create
234+
235+
#### Returns
236+
237+
[Agent](./automation.generativeai.agents.agent.md)<br>
238+
Agent
239+
240+
### **MessgeFromResponse(LLMResponse)**
241+
242+
Converts the LLMResponse to ChatMessage
243+
244+
```csharp
245+
protected internal static ChatMessage MessgeFromResponse(LLMResponse response)
246+
```
247+
248+
#### Parameters
249+
250+
`response` [LLMResponse](./automation.generativeai.interfaces.llmresponse.md)<br>
251+
A response returned from the language model.
252+
253+
#### Returns
254+
255+
[ChatMessage](./automation.generativeai.interfaces.chatmessage.md)<br>
256+
ChatMessage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# AgentAction
2+
3+
Namespace: Automation.GenerativeAI.Agents
4+
5+
Represents agent action that can be executed as current step. It holdes a tool
6+
and execution context so that the tool can be executed.
7+
8+
```csharp
9+
public class AgentAction
10+
```
11+
12+
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [AgentAction](./automation.generativeai.agents.agentaction.md)
13+
14+
## Properties
15+
16+
### **Parameters**
17+
18+
List of input parameters required for the tool/action.
19+
20+
```csharp
21+
public IEnumerable<string> Parameters { get; }
22+
```
23+
24+
#### Property Value
25+
26+
[IEnumerable&lt;String&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)<br>
27+
28+
### **Tool**
29+
30+
Gets the tool that this action can execute.
31+
32+
```csharp
33+
public IFunctionTool Tool { get; protected set; }
34+
```
35+
36+
#### Property Value
37+
38+
[IFunctionTool](./automation.generativeai.interfaces.ifunctiontool.md)<br>
39+
40+
### **Thought**
41+
42+
Gets the reasoning for this action.
43+
44+
```csharp
45+
public string Thought { get; set; }
46+
```
47+
48+
#### Property Value
49+
50+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
51+
52+
### **ExecutionContext**
53+
54+
Execution context for this action
55+
56+
```csharp
57+
public ExecutionContext ExecutionContext { get; private set; }
58+
```
59+
60+
#### Property Value
61+
62+
[ExecutionContext](./automation.generativeai.interfaces.executioncontext.md)<br>
63+
64+
## Constructors
65+
66+
### **AgentAction(IFunctionTool, ExecutionContext, String)**
67+
68+
Constructor
69+
70+
```csharp
71+
public AgentAction(IFunctionTool tool, ExecutionContext executionContext, string thought)
72+
```
73+
74+
#### Parameters
75+
76+
`tool` [IFunctionTool](./automation.generativeai.interfaces.ifunctiontool.md)<br>
77+
The tool this action can execute.
78+
79+
`executionContext` [ExecutionContext](./automation.generativeai.interfaces.executioncontext.md)<br>
80+
Execution context to execute the tool.
81+
82+
`thought` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
83+
The reasoning of the thought for this action.
84+
85+
## Methods
86+
87+
### **ExecuteAsync()**
88+
89+
Executes the given tool asynchronously.
90+
91+
```csharp
92+
public Task<string> ExecuteAsync()
93+
```
94+
95+
#### Returns
96+
97+
[Task&lt;String&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)<br>
98+
Output string returned from the tool after execution.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# AgentType
2+
3+
Namespace: Automation.GenerativeAI.Agents
4+
5+
Represents a type of Agent
6+
7+
```csharp
8+
public enum AgentType
9+
```
10+
11+
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [AgentType](./automation.generativeai.agents.agenttype.md)<br>
12+
Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible)
13+
14+
## Fields
15+
16+
| Name | Value | Description |
17+
| --- | --: | --- |
18+
| FunctionAgent | 0 | Represents an agent that makes use of OpenAI Function call capability. |

0 commit comments

Comments
 (0)