Skip to content

Commit 819688d

Browse files
committed
Version upgrade to 1.1 and minor documentation update
1 parent c16f7df commit 819688d

22 files changed

+203
-63
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ examples/*/obj
1212
*.nupkg
1313
docs/automation.generativeai.stores.data.md
1414
docs/automation.generativeai.stores.embeddingresult.md
15+
build/GenerativeAI/

build/GenerativeAI.zip

406 KB
Binary file not shown.

build/buildpackage.bat

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
@cd /d "%~dp0"
3+
del /f/q/s GenerativeAI\*
4+
del /f/q/s GenerativeAI*
5+
IF NOT EXIST GenerativeAI (mkdir GenerativeAI)
6+
copy ..\bin\AnyCPU\Release\*.dll GenerativeAI
7+
copy ..\bin\AnyCPU\Release\GenerativeAI*.xml GenerativeAI
8+
tar.exe -a -c -f GenerativeAI.zip GenerativeAI\*

docs/automation.generativeai.application.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static Task<string> GetResponseAsync(string message, double temperature)
121121
User's message
122122

123123
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
124-
A value between 0 to 2, that controls randomness of the response.
124+
A value between 0 to 1, that controls randomness of the response.
125125
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
126126

127127
#### Returns
@@ -143,6 +143,7 @@ public static string GetResponse(string message, double temperature)
143143
User's message
144144

145145
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
146+
A value between 0 and 1 to control the randomness of the response.
146147

147148
#### Returns
148149

@@ -222,7 +223,7 @@ Full path of vector database to get the context.
222223
User message for which response is required.
223224

224225
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
225-
A value between 0 and 2 to control the randomness of the response.
226+
A value between 0 and 1 to control the randomness of the response.
226227

227228
#### Returns
228229

@@ -256,7 +257,7 @@ Full path of vector database to get the context.
256257
User message for which response is required.
257258

258259
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
259-
A value between 0 and 2 to control the randomness of the response.
260+
A value between 0 and 1 to control the randomness of the response.
260261

261262
#### Returns
262263

@@ -329,7 +330,7 @@ Name of the function that was executed.
329330
Output returned from the function call as string(json).
330331

331332
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
332-
A value between 0 and 2 to control the randomness of the response.
333+
A value between 0 and 1 to control the randomness of the response.
333334

334335
#### Returns
335336

docs/automation.generativeai.dllfunctiontools.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Implements a FunctionToolSet for a .net dll. Using reflection it
77
to provide it as toolset.
88

99
```csharp
10-
public class DLLFunctionTools : Automation.GenerativeAI.Interfaces.IFunctionToolSet, System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.0.8640.40506, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
10+
public class DLLFunctionTools : Automation.GenerativeAI.Interfaces.IFunctionToolSet, System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.1.8641.34377, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
1111
```
1212

1313
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [DLLFunctionTools](./automation.generativeai.dllfunctiontools.md)<br>

docs/automation.generativeai.interfaces.iconversation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Task<ChatMessage> GetResponseAsync(double temperature)
104104
#### Parameters
105105

106106
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
107-
A value between 0 to 2, that controls randomness of the response.
107+
A value between 0 to 1, that controls randomness of the response.
108108
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
109109

110110
#### Returns

docs/automation.generativeai.interfaces.ifunctiontoolset.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Namespace: Automation.GenerativeAI.Interfaces
55
Represents a function toolset that provides multiple functions
66

77
```csharp
8-
public interface IFunctionToolSet : System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.0.8640.40506, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
8+
public interface IFunctionToolSet : System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.1.8641.34377, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
99
```
1010

1111
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)

docs/automation.generativeai.interfaces.ilanguagemodel.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ A list of messages as a history. The Response is generated for
3939
the last message using the history of messages as context.
4040

4141
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
42-
A value between 0 to 2, that controls randomness of the response.
42+
A value between 0 to 1, that controls randomness of the response.
4343
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
4444

4545
#### Returns
@@ -67,7 +67,7 @@ A list of function descriptors to match if the request resolves
6767
to function calling.
6868

6969
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
70-
A value between 0 to 2, that controls randomness of the response.
70+
A value between 0 to 1, that controls randomness of the response.
7171
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
7272

7373
#### Returns

docs/automation.generativeai.llm.mocklanguagemodel.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public Task<LLMResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, dou
5959
List of chat messages
6060

6161
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
62-
A value between 0 to 2, that controls randomness of the response.
63-
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
62+
Not in use.
6463

6564
#### Returns
6665

@@ -87,8 +86,7 @@ A list of function descriptors to match if the request resolves
8786
to function calling.
8887

8988
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
90-
A value between 0 to 2, that controls randomness of the response.
91-
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
89+
Not in use.
9290

9391
#### Returns
9492

@@ -114,8 +112,7 @@ A list of function descriptors to match if the request resolves
114112
to function calling.
115113

116114
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
117-
A value between 0 to 2, that controls randomness of the response.
118-
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
115+
Not in use.
119116

120117
#### Returns
121118

docs/automation.generativeai.llm.openailanguagemodel.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ A list of messages as a history. The Response is generated for
6161
the last message using the history of messages as context.
6262

6363
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
64-
A value between 0 to 2, that controls randomness of the response.
64+
A value between 0 to 1, that controls randomness of the response.
6565
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
6666

6767
#### Returns
@@ -89,7 +89,7 @@ A list of function descriptors to match if the request resolves
8989
to function calling.
9090

9191
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
92-
A value between 0 to 2, that controls randomness of the response.
92+
A value between 0 to 1, that controls randomness of the response.
9393
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
9494

9595
#### Returns
@@ -144,7 +144,7 @@ A list of function descriptors to match if the request resolves
144144
to function calling.
145145

146146
`temperature` [Double](https://docs.microsoft.com/en-us/dotnet/api/system.double)<br>
147-
A value between 0 to 2, that controls randomness of the response.
147+
A value between 0 to 1, that controls randomness of the response.
148148
Higher temperature will lead to more randomness. Lower temperature will be more deterministic.
149149

150150
#### Returns

docs/automation.generativeai.tools.dataextractortool.md

+38
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,44 @@ public static DataExtractorTool Create()
6969

7070
#### Returns
7171

72+
[DataExtractorTool](./automation.generativeai.tools.dataextractortool.md)<br>
73+
A new DataExtractorTool
74+
75+
### **WithPrompt(String)**
76+
77+
Allows user to modify the default extractor prompt. The default prompt is as follows:
78+
"Extract arguments and values from the following text only based on function specification
79+
provided, do not include extra parameter. {{$text}}"
80+
81+
```csharp
82+
public DataExtractorTool WithPrompt(string promptTemplate)
83+
```
84+
85+
#### Parameters
86+
87+
`promptTemplate` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
88+
Prompt template string with one input variable.
89+
90+
#### Returns
91+
92+
[DataExtractorTool](./automation.generativeai.tools.dataextractortool.md)<br>
93+
Updated DataExtractorTool
94+
95+
### **WithTemperature(Double)**
96+
97+
Allows user to override the temperature setting for data extraction. The default value is 0.8
98+
99+
```csharp
100+
public DataExtractorTool 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 control the randomness of the response.
107+
108+
#### Returns
109+
72110
[DataExtractorTool](./automation.generativeai.tools.dataextractortool.md)<br>
73111

74112
### **WithLanguageModel(ILanguageModel)**

docs/automation.generativeai.tools.toolscollection.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Namespace: Automation.GenerativeAI.Tools
55
Represents a simple collection of tools as a toolset
66

77
```csharp
8-
public class ToolsCollection : Automation.GenerativeAI.Interfaces.IFunctionToolSet, System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.0.8640.40506, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
8+
public class ToolsCollection : Automation.GenerativeAI.Interfaces.IFunctionToolSet, System.Collections.Generic.IEnumerable`1[[Automation.GenerativeAI.Interfaces.IFunctionTool, GenerativeAI, Version=1.1.8641.34377, Culture=neutral, PublicKeyToken=null]], System.Collections.IEnumerable
99
```
1010

1111
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ToolsCollection](./automation.generativeai.tools.toolscollection.md)<br>

examples/FunctionTools/FunctionTools.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
<None Include="App.config" />
5353
</ItemGroup>
5454
<ItemGroup>
55+
<ProjectReference Include="..\..\src\GenerativeAI.Tools\GenerativeAI.Tools.csproj">
56+
<Project>{67f97e97-6da9-4f9e-905a-4b252a683322}</Project>
57+
<Name>GenerativeAI.Tools</Name>
58+
</ProjectReference>
5559
<ProjectReference Include="..\..\src\GenerativeAI\GenerativeAI.csproj">
5660
<Project>{bc19718c-9636-4bbe-8965-90f70dfd17b2}</Project>
5761
<Name>GenerativeAI</Name>

nuget/GenAI.NET.nuspec

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
33
<metadata>
44
<id>GenAI.NET</id>
5-
<version>1.0.8626.20106</version>
5+
<version>1.1.8640.40728</version>
66
<authors>Automation Agent</authors>
77
<owners>Automation Agent</owners>
88
<projectUrl>https://github.com/automaze1/GenAI.NET</projectUrl>
@@ -11,11 +11,14 @@
1111
<description>Assemblies required to create a generative AI application that can interact with a large language model. Contains the following files:
1212
1) GenerativeAI.dll
1313
2) GenerativeAI.UX.dll
14-
</description>
14+
3) GenerativeAI.Tools.dll
15+
</description>
1516
<summary>This package provides a library to create generative AI applications.</summary>
1617
<copyright>Copyright Automation Agent 2023</copyright>
1718
<dependencies>
1819
<group targetFramework=".NETFramework4.7.2">
20+
<dependency id="PDFsharp" version="1.50.5147" />
21+
<dependency id="HtmlAgilityPack" version="1.11.51" />
1922
</group>
2023
</dependencies>
2124
</metadata>
@@ -24,6 +27,8 @@
2427
<file src="..\bin\AnyCPU\Release\GenerativeAI.xml" target="lib\net472" />
2528
<file src="..\bin\AnyCPU\Release\GenerativeAI.UX.dll" target="lib\net472" />
2629
<file src="..\bin\AnyCPU\Release\GenerativeAI.UX.xml" target="lib\net472" />
30+
<file src="..\bin\AnyCPU\Release\GenerativeAI.Tools.dll" target="lib\net472" />
31+
<file src="..\bin\AnyCPU\Release\GenerativeAI.Tools.xml" target="lib\net472" />
2732
<file src=".\icon.png" target="images\" />
2833
</files>
2934
</package>

src/Common/AssemblySharedInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
// You can specify all the values or you can default the Build and Revision Numbers
4242
// by using the '*' as shown below:
4343
// [assembly: AssemblyVersion("1.0.*")]
44-
[assembly: AssemblyVersion("1.0.*")]
44+
[assembly: AssemblyVersion("1.1.*")]

src/GenerativeAI.Tools/WebContentExtractor.cs

+53-4
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,61 @@ public static string GetTextContentFromWebpage(string url)
2121

2222
var doc = htmlweb.Load(url);
2323

24+
//search the root content
25+
var nodes = doc.DocumentNode.SelectNodes(@"//div[@id='mw-content-text']");
26+
if (nodes == null || nodes.Count == 0)
27+
{
28+
nodes = new HtmlNodeCollection(doc.DocumentNode)
29+
{
30+
doc.DocumentNode
31+
};
32+
}
33+
2434
using (var sw = new StringWriter())
2535
{
26-
// Convert the HTML string to plain text
27-
ConvertTo(node: doc.DocumentNode,
28-
outText: sw,
29-
counters: new Dictionary<HtmlNode, int>());
36+
foreach (var node in nodes)
37+
{
38+
// Convert the HTML string to plain text
39+
ConvertTo(node: node,
40+
outText: sw,
41+
counters: new Dictionary<HtmlNode, int>());
42+
}
43+
44+
sw.Flush();
45+
return sw.ToString();
46+
}
47+
}
48+
49+
/// <summary>
50+
/// Extracts or parses the text content from a given html content.
51+
/// </summary>
52+
/// <param name="html">A string containing HTML document.</param>
53+
/// <returns>The plain text version of the HTML content.</returns>
54+
public static string GetTextFromHtml(string html)
55+
{
56+
var doc = new HtmlDocument();
57+
doc.LoadHtml(html);
58+
59+
//search the root content
60+
var nodes = doc.DocumentNode.SelectNodes(@"//div[@id='mw-content-text']");
61+
if (nodes == null || nodes.Count == 0)
62+
{
63+
nodes = new HtmlNodeCollection(doc.DocumentNode)
64+
{
65+
doc.DocumentNode
66+
};
67+
}
68+
69+
using (var sw = new StringWriter())
70+
{
71+
foreach(var node in nodes)
72+
{
73+
// Convert the HTML string to plain text
74+
ConvertTo(node: node,
75+
outText: sw,
76+
counters: new Dictionary<HtmlNode, int>());
77+
}
78+
3079
sw.Flush();
3180
return sw.ToString();
3281
}

src/GenerativeAI/Application.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static void SetLogFilePath(string logFilePath)
127127
/// Gets AI assitant's response for a given message. This request doesn't have any memory.
128128
/// </summary>
129129
/// <param name="message">User's message</param>
130-
/// <param name="temperature">A value between 0 to 2, that controls randomness of the response.
130+
/// <param name="temperature">A value between 0 to 1, that controls randomness of the response.
131131
/// Higher temperature will lead to more randomness. Lower temperature will be more deterministic.</param>
132132
/// <returns>Response returned by the AI assitant.</returns>
133133
public static async Task<string> GetResponseAsync(string message, double temperature)
@@ -160,7 +160,7 @@ public static async Task<string> GetResponseAsync(string message, double tempera
160160
/// Sends message to language model to get AI assistant's response.
161161
/// </summary>
162162
/// <param name="message">User's message</param>
163-
/// <param name="temperature"></param>
163+
/// <param name="temperature">A value between 0 and 1 to control the randomness of the response.</param>
164164
/// <returns>Response message</returns>
165165
public static string GetResponse(string message, double temperature)
166166
{
@@ -240,7 +240,7 @@ public static IVectorStore CreateVectorDatabaseForSemanticSearch(string source,
240240
/// <param name="systemctx">System message to specify, how to process a given message.</param>
241241
/// <param name="vdbpath">Full path of vector database to get the context.</param>
242242
/// <param name="message">User message for which response is required.</param>
243-
/// <param name="temperature">A value between 0 and 2 to control the randomness of the response.</param>
243+
/// <param name="temperature">A value between 0 and 1 to control the randomness of the response.</param>
244244
/// <returns>Returns the AI assitant's response.</returns>
245245
/// <exception cref="System.Exception"></exception>
246246
public static async Task<string> GetResponseFromContextAsync(string sessionid, string systemctx, string vdbpath, string message, double temperature)
@@ -287,7 +287,7 @@ public static async Task<string> GetResponseFromContextAsync(string sessionid, s
287287
/// <param name="systemctx">System message to specify, how to process a given message.</param>
288288
/// <param name="vdbpath">Full path of vector database to get the context.</param>
289289
/// <param name="message">User message for which response is required.</param>
290-
/// <param name="temperature">A value between 0 and 2 to control the randomness of the response.</param>
290+
/// <param name="temperature">A value between 0 and 1 to control the randomness of the response.</param>
291291
/// <returns>Returns the AI assitant's response.</returns>
292292
/// <exception cref="System.Exception"></exception>
293293
public static string GetResponseFromContext(string sessionid, string systemctx, string vdbpath, string message, double temperature)
@@ -374,7 +374,7 @@ public static List<string> AddToolsFromDLL(string dllpath)
374374
/// <param name="sessionid">The session id for the conversation.</param>
375375
/// <param name="functionName">Name of the function that was executed.</param>
376376
/// <param name="message">Output returned from the function call as string(json).</param>
377-
/// <param name="temperature">A value between 0 and 2 to control the randomness of the response.</param>
377+
/// <param name="temperature">A value between 0 and 1 to control the randomness of the response.</param>
378378
/// <returns>The response from the language model.</returns>
379379
public static string AddFunctionMessage(string sessionid, string functionName, string message, double temperature)
380380
{

0 commit comments

Comments
 (0)