Skip to content

MemoryStore and AzureOpenAILanguageModel implementation #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified build/GenerativeAI.zip
Binary file not shown.
23 changes: 18 additions & 5 deletions docs/automation.generativeai.agents.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,31 @@ Maximum number of steps that can be executed.
[Agent](./automation.generativeai.agents.agent.md)<br>
This Agent

### **GetNextActionAsync(List&lt;ChatMessage&gt;)**
### **WithMemoryStore(IMemoryStore)**

Provides a next agent action based on the given message history.
Sets the memory store for the agent

```csharp
protected abstract Task<AgentAction> GetNextActionAsync(List<ChatMessage> messages)
public Agent WithMemoryStore(IMemoryStore memory)
```

#### Parameters

`messages` [List&lt;ChatMessage&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)<br>
History of messages as a list
`memory` [IMemoryStore](./automation.generativeai.interfaces.imemorystore.md)<br>
External memory store

#### Returns

[Agent](./automation.generativeai.agents.agent.md)<br>
This Agent

### **GetNextActionAsync()**

Provides a next agent action based on the given message history.

```csharp
protected abstract Task<AgentAction> GetNextActionAsync()
```

#### Returns

Expand Down
100 changes: 99 additions & 1 deletion docs/automation.generativeai.application.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal static TextProviderService GetTextProviderService()
Application must be initialized before making any request.

```csharp
public void Initialize(string llmtype, string model, string apikey, string logFilePath)
public static void Initialize(string llmtype, string model, string apikey, string logFilePath)
```

#### Parameters
Expand All @@ -100,6 +100,37 @@ Full path for log files.

[NotImplementedException](https://docs.microsoft.com/en-us/dotnet/api/system.notimplementedexception)<br>

### **InitializeAzureOpenAI(String, String, String, String, String, String, String)**

Initializes AzureOpenAI language model. Application must be initialized before making any request.

```csharp
public static void InitializeAzureOpenAI(string azureEndpoint, string gptDeployment, string embeddingDeployment, string apiversion, string apiKey, string model, string logFilePath)
```

#### Parameters

`azureEndpoint` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Endpoint URL for Azure OpenAI service

`gptDeployment` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Deployment Name for GPT model

`embeddingDeployment` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Deployment Name for text embedding model

`apiversion` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
API version

`apiKey` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
ApiKey for the language model

`model` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Model name to be used for chat completion

`logFilePath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Full path for log file.

### **SetLogFilePath(String)**

Sets Log file path
Expand Down Expand Up @@ -369,6 +400,73 @@ A JSON string with key value pairs as a context holding variable values to execu
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Output string as a result of the execution if successful, else error message starting with ERROR.

### **ExecuteTool(String, String, String)**

Executes a given tool with the arguments passed and returns the
output as a string. For complex objects it returns JSON string.

```csharp
public static string ExecuteTool(string sessionName, string toolName, string executionContext)
```

#### Parameters

`sessionName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Name of the session to access memory store

`toolName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Name of the tool to execute

`executionContext` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
A JSON string with key value pairs as a context holding variable values to execute the tool.

#### Returns

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Output string as a result of the execution if successful, else error message starting with ERROR.

### **RestoreSession(String, String)**

Restores a session with the given session file.

```csharp
public static string RestoreSession(string sessionName, string sessionFilePath)
```

#### Parameters

`sessionName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Name of the session

`sessionFilePath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Full path of the session file

#### Returns

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Status of the operation

### **SaveSession(String, String)**

Saves a given session to a file.

```csharp
public static string SaveSession(string sessionName, string sessionFilePath)
```

#### Parameters

`sessionName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Name of the session

`sessionFilePath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Full path of the session file to save the session.

#### Returns

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Status of the operation

### **GetExecutionResult(String)**

Gets the execution result for a given tool. Useful in getting intermediate results.
Expand Down
2 changes: 1 addition & 1 deletion docs/automation.generativeai.dllfunctiontools.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Implements a FunctionToolSet for a .net dll. Using reflection it
to provide it as toolset.

```csharp
public class DLLFunctionTools : Automation.GenerativeAI.Interfaces.IFunctionToolSet, System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.1.8661.30687, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
public class DLLFunctionTools : Automation.GenerativeAI.Interfaces.IFunctionToolSet, System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.2.8734.98, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
```

Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [DLLFunctionTools](./automation.generativeai.dllfunctiontools.md)<br>
Expand Down
2 changes: 1 addition & 1 deletion docs/automation.generativeai.interfaces.chatmessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
Role of the messenger

```csharp
public string role { get; private set; }
public string role { get; set; }
```

#### Property Value
Expand Down
46 changes: 46 additions & 0 deletions docs/automation.generativeai.interfaces.executioncontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)

## Properties

### **MemoryStore**

Gets the memory store for the context

```csharp
public IMemoryStore MemoryStore { get; }
```

#### Property Value

[IMemoryStore](./automation.generativeai.interfaces.imemorystore.md)<br>

### **Item**

```csharp
Expand Down Expand Up @@ -45,6 +57,22 @@ public ExecutionContext(Dictionary<string, object> parameters)
`parameters` [Dictionary&lt;String, Object&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2)<br>
Parameters dictionary

### **ExecutionContext(IMemoryStore, Dictionary&lt;String, Object&gt;)**

Creates ExecutionContext with memory and parameters

```csharp
public ExecutionContext(IMemoryStore memoryStore, Dictionary<string, object> parameters)
```

#### Parameters

`memoryStore` [IMemoryStore](./automation.generativeai.interfaces.imemorystore.md)<br>
Memory

`parameters` [Dictionary&lt;String, Object&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2)<br>
Parameters dictionary

## Methods

### **GetParameters()**
Expand All @@ -57,6 +85,24 @@ internal IDictionary<string, object> GetParameters()

[IDictionary&lt;String, Object&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.idictionary-2)<br>

### **WithMemory(IMemoryStore)**

Sets the memory store

```csharp
public ExecutionContext WithMemory(IMemoryStore memory)
```

#### Parameters

`memory` [IMemoryStore](./automation.generativeai.interfaces.imemorystore.md)<br>
Memory

#### Returns

[ExecutionContext](./automation.generativeai.interfaces.executioncontext.md)<br>
Updated ExecutionContext

### **TryGetResult(String, Object&)**

Tries to get the result for specific tool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Dictionary<string, object> function_call { get; set; }
Role of the messenger

```csharp
public string role { get; }
public string role { get; set; }
```

#### Property Value
Expand Down
2 changes: 1 addition & 1 deletion docs/automation.generativeai.interfaces.functionmessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public string name { get; set; }
Role of the messenger

```csharp
public string role { get; }
public string role { get; set; }
```

#### Property Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Namespace: Automation.GenerativeAI.Interfaces
Represents a function toolset that provides multiple functions

```csharp
public interface IFunctionToolSet : System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.1.8661.30687, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
public interface IFunctionToolSet : System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.2.8734.98, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
```

Implements [IEnumerable&lt;IFunctionTool&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerable)
Expand Down
34 changes: 34 additions & 0 deletions docs/automation.generativeai.interfaces.igenerativeaiservice.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,40 @@ API Key, if passed empty string then it will try to get the
#### Returns

[ILanguageModel](./automation.generativeai.interfaces.ilanguagemodel.md)<br>
OpenAI Language Model instance

### **CreateAzureOpenAIModel(String, String, String, String, String, String)**

Creates an instance of Azure OpenAI Language Model

```csharp
ILanguageModel CreateAzureOpenAIModel(string model, string azureEndpoint, string gptDeployment, string embeddingDeployment, string apiversion, string apiKey)
```

#### Parameters

`model` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Azure OpenAI model name

`azureEndpoint` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Endpoint URL for Azure OpenAI service

`gptDeployment` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Deployment Name for GPT model

`embeddingDeployment` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
Deployment Name for text embedding model

`apiversion` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
API version

`apiKey` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
ApiKey for the language model

#### Returns

[ILanguageModel](./automation.generativeai.interfaces.ilanguagemodel.md)<br>
Azure OpenAI Language Model instance

### **CreateVectorStore(IVectorTransformer)**

Expand Down
12 changes: 12 additions & 0 deletions docs/automation.generativeai.interfaces.ilanguagemodel.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ public abstract string ModelName { get; }

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>

### **VectorTransformer**

Gets vector transformer for semantic search

```csharp
public abstract IVectorTransformer VectorTransformer { get; }
```

#### Property Value

[IVectorTransformer](./automation.generativeai.interfaces.ivectortransformer.md)<br>

## Methods

### **GetResponseAsync(IEnumerable&lt;ChatMessage&gt;, Double)**
Expand Down
Loading