-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
2,086 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@ECHO off | ||
cls | ||
|
||
ECHO Deleting all BIN and OBJ folders... | ||
ECHO. | ||
|
||
FOR /d /r . %%d in (bin,obj,node_modules,Logs) DO ( | ||
IF EXIST "%%d" ( | ||
ECHO %%d | FIND /I "\node_modules\" > Nul && ( | ||
ECHO.Skipping: %%d | ||
) || ( | ||
ECHO.Deleting: %%d | ||
rd /s/q "%%d" | ||
) | ||
) | ||
) | ||
|
||
ECHO. | ||
ECHO.BIN and OBJ folders have been successfully deleted. Press any key to exit. | ||
pause > nul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.7.34202.233 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AC161F1D-EC76-48D2-86A3-B52584618D49}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerativeAI", "src\GenerativeAI\GenerativeAI.csproj", "{3B56ADE1-2A08-4774-A7C9-7CDB5EE5735B}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FCCDE15A-B121-4D6C-BD56-D1B043A26F18}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerativeAI.Tests", "tests\GenerativeAI.Tests\GenerativeAI.Tests.csproj", "{734EA3CA-DB49-4FD3-ABB5-E185231B1818}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerativeAI.Generators", "src\GenerativeAI.Generators\GenerativeAI.Generators.csproj", "{6B247114-6727-4CE5-8C9F-0C361776589E}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenerativeAI.IntegrationTests", "tests\GenerativeAI.IntegrationTests\GenerativeAI.IntegrationTests.csproj", "{3C094E6B-A3FB-43BA-920B-0E27DB3F1B3F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{3B56ADE1-2A08-4774-A7C9-7CDB5EE5735B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3B56ADE1-2A08-4774-A7C9-7CDB5EE5735B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3B56ADE1-2A08-4774-A7C9-7CDB5EE5735B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3B56ADE1-2A08-4774-A7C9-7CDB5EE5735B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{734EA3CA-DB49-4FD3-ABB5-E185231B1818}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{734EA3CA-DB49-4FD3-ABB5-E185231B1818}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{734EA3CA-DB49-4FD3-ABB5-E185231B1818}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{734EA3CA-DB49-4FD3-ABB5-E185231B1818}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{6B247114-6727-4CE5-8C9F-0C361776589E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6B247114-6727-4CE5-8C9F-0C361776589E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6B247114-6727-4CE5-8C9F-0C361776589E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6B247114-6727-4CE5-8C9F-0C361776589E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{3C094E6B-A3FB-43BA-920B-0E27DB3F1B3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3C094E6B-A3FB-43BA-920B-0E27DB3F1B3F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3C094E6B-A3FB-43BA-920B-0E27DB3F1B3F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3C094E6B-A3FB-43BA-920B-0E27DB3F1B3F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{3B56ADE1-2A08-4774-A7C9-7CDB5EE5735B} = {AC161F1D-EC76-48D2-86A3-B52584618D49} | ||
{734EA3CA-DB49-4FD3-ABB5-E185231B1818} = {FCCDE15A-B121-4D6C-BD56-D1B043A26F18} | ||
{6B247114-6727-4CE5-8C9F-0C361776589E} = {AC161F1D-EC76-48D2-86A3-B52584618D49} | ||
{3C094E6B-A3FB-43BA-920B-0E27DB3F1B3F} = {FCCDE15A-B121-4D6C-BD56-D1B043A26F18} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {FFF3E8BB-BACD-4376-8E33-55D6E8A30BE0} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,91 @@ | ||
# Google_GenerativeAI | ||
# Google GenerativeAI (Gemini) | ||
<!-- @import "[TOC]" {cmd="toc" depthFrom=1 depthTo=6 orderedList=false} --> | ||
|
||
<!-- code_chunk_output --> | ||
|
||
- [Google GenerativeAI (Gemini)](#google-generativeai-gemini) | ||
- [Usage](#usage) | ||
- [Quick Start](#quick-start) | ||
- [Function Calling](#function-calling) | ||
|
||
<!-- /code_chunk_output --> | ||
|
||
|
||
Unofficial C# SDK based on Google GenerativeAI (Gemini Pro) REST APIs. | ||
|
||
This package includes C# Source Generator which allows you to define functions natively through a C# interface, | ||
and also provides extensions that make it easier to call this interface later. | ||
In addition to easy function implementation and readability, | ||
it generates Args classes, extension methods to easily pass a functions to API, | ||
and extension methods to simply call a function via json and return json. | ||
Currently only System.Text.Json is supported. | ||
|
||
### Usage | ||
|
||
### Quick Start | ||
|
||
1) [Obtain an API](https://makersuite.google.com/app/apikey) key to use with the Google AI SDKs. | ||
|
||
```csharp | ||
var apiKey = 'Your API Key'; | ||
|
||
var model = new GenerativeModel(apiKey); | ||
|
||
var res = await model.GenerateContentAsync("How are you doing?"); | ||
|
||
``` | ||
|
||
### Function Calling | ||
|
||
```csharp | ||
using GenerativeAI; | ||
|
||
public enum Unit | ||
{ | ||
Celsius, | ||
Fahrenheit, | ||
} | ||
|
||
public class Weather | ||
{ | ||
public string Location { get; set; } = string.Empty; | ||
public double Temperature { get; set; } | ||
public Unit Unit { get; set; } | ||
public string Description { get; set; } = string.Empty; | ||
} | ||
|
||
[GenerativeAIFunctions] | ||
public interface IWeatherFunctions | ||
{ | ||
[Description("Get the current weather in a given location")] | ||
public Task<Weather> GetCurrentWeatherAsync( | ||
[Description("The city and state, e.g. San Francisco, CA")] string location, | ||
Unit unit = Unit.Celsius, | ||
CancellationToken cancellationToken = default); | ||
} | ||
|
||
public class WeatherService : IWeatherFunctions | ||
{ | ||
public Task<Weather> GetCurrentWeatherAsync(string location, Unit unit = Unit.Celsius, CancellationToken cancellationToken = default) | ||
{ | ||
return Task.FromResult(new Weather | ||
{ | ||
Location = location, | ||
Temperature = 22.0, | ||
Unit = unit, | ||
Description = "Sunny", | ||
}); | ||
} | ||
} | ||
|
||
WeatherService service = new WeatherService(); | ||
|
||
var apiKey = Environment.GetEnvironmentVariable("Gemini_API_Key", EnvironmentVariableTarget.User); | ||
|
||
var model = new GenerativeModel(apiKey, functions:service.AsFunctions(),calls:service.AsCalls()); | ||
|
||
var result = await model.GenerateContentAsync("What is the weather in San Francisco today?"); | ||
|
||
Console.WriteLine(result); | ||
``` | ||
|
23 changes: 23 additions & 0 deletions
23
src/GenerativeAI.Generators/GenerativeAI.Generators.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<GenerateDocumentationFile>false</GenerateDocumentationFile> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules> | ||
<LangVersion>10</LangVersion> | ||
<NoWarn>$(NoWarn);CA1014;CA1031;CA1308</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="IsExternalInit" Version="1.0.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" PrivateAssets="all" /> | ||
<PackageReference Include="H.Generators.Extensions" Version="1.20.0" PrivateAssets="all" /> | ||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.