Skip to content

Commit 967741a

Browse files
committed
Initial commit
0 parents  commit 967741a

40 files changed

+3990
-0
lines changed

.editorconfig

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# EditorConfig for SharpAIKit
2+
# https://editorconfig.org
3+
4+
root = true
5+
6+
# All files
7+
[*]
8+
indent_style = space
9+
indent_size = 4
10+
end_of_line = lf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
# C# files
16+
[*.cs]
17+
indent_size = 4
18+
19+
# C# code style settings
20+
dotnet_sort_system_directives_first = true
21+
dotnet_separate_import_directive_groups = false
22+
23+
# Use "var" everywhere
24+
csharp_style_var_for_built_in_types = true:suggestion
25+
csharp_style_var_when_type_is_apparent = true:suggestion
26+
csharp_style_var_elsewhere = true:suggestion
27+
28+
# Prefer expression-bodied members
29+
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
30+
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
31+
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
32+
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
33+
csharp_style_expression_bodied_indexers = when_on_single_line:suggestion
34+
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
35+
36+
# Prefer pattern matching
37+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
38+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
39+
40+
# Null checking preferences
41+
csharp_style_throw_expression = true:suggestion
42+
csharp_style_conditional_delegate_call = true:suggestion
43+
44+
# New line preferences
45+
csharp_new_line_before_open_brace = all
46+
csharp_new_line_before_else = true
47+
csharp_new_line_before_catch = true
48+
csharp_new_line_before_finally = true
49+
50+
# Indentation preferences
51+
csharp_indent_case_contents = true
52+
csharp_indent_switch_labels = true
53+
54+
# Space preferences
55+
csharp_space_after_cast = false
56+
csharp_space_after_keywords_in_control_flow_statements = true
57+
csharp_space_between_method_declaration_parameter_list_parentheses = false
58+
csharp_space_between_method_call_parameter_list_parentheses = false
59+
60+
# XML project files
61+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
62+
indent_size = 2
63+
64+
# XML config files
65+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
66+
indent_size = 2
67+
68+
# JSON files
69+
[*.json]
70+
indent_size = 2
71+
72+
# YAML files
73+
[*.{yml,yaml}]
74+
indent_size = 2
75+
76+
# Markdown files
77+
[*.md]
78+
trim_trailing_whitespace = false
79+
80+
# Shell scripts
81+
[*.sh]
82+
end_of_line = lf
83+

.github/workflows/build.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v4
19+
with:
20+
dotnet-version: '8.0.x'
21+
22+
- name: Restore dependencies
23+
run: dotnet restore
24+
25+
- name: Build
26+
run: dotnet build --no-restore --configuration Release
27+
28+
- name: Run tests
29+
run: dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage"
30+
31+
- name: Upload coverage reports
32+
uses: codecov/codecov-action@v3
33+
with:
34+
files: ./tests/**/coverage.cobertura.xml
35+
fail_ci_if_error: false
36+
37+
pack:
38+
runs-on: ubuntu-latest
39+
needs: build
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Setup .NET
46+
uses: actions/setup-dotnet@v4
47+
with:
48+
dotnet-version: '8.0.x'
49+
50+
- name: Restore dependencies
51+
run: dotnet restore
52+
53+
- name: Create NuGet package
54+
run: dotnet pack src/SharpAIKit/SharpAIKit.csproj --configuration Release --output ./nupkg
55+
56+
- name: Upload NuGet package artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: nuget-package
60+
path: ./nupkg/*.nupkg
61+
retention-days: 7
62+

.gitignore

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Build results
2+
[Dd]ebug/
3+
[Dd]ebugPublic/
4+
[Rr]elease/
5+
[Rr]eleases/
6+
x64/
7+
x86/
8+
[Ww][Ii][Nn]32/
9+
[Aa][Rr][Mm]/
10+
[Aa][Rr][Mm]64/
11+
bld/
12+
[Bb]in/
13+
[Oo]bj/
14+
[Ll]og/
15+
[Ll]ogs/
16+
17+
# Visual Studio
18+
.vs/
19+
*.user
20+
*.suo
21+
*.userosscache
22+
*.sln.docstates
23+
*.rsuser
24+
25+
# Rider
26+
.idea/
27+
*.sln.iml
28+
29+
# VS Code
30+
.vscode/
31+
32+
# NuGet
33+
*.nupkg
34+
*.snupkg
35+
**/[Pp]ackages/*
36+
!**/[Pp]ackages/build/
37+
*.nuget.props
38+
*.nuget.targets
39+
project.lock.json
40+
project.fragment.lock.json
41+
artifacts/
42+
43+
# .NET Core
44+
project.lock.json
45+
project.fragment.lock.json
46+
artifacts/
47+
48+
# Test Results
49+
[Tt]est[Rr]esult*/
50+
[Bb]uild[Ll]og.*
51+
*.trx
52+
TestResult.xml
53+
coverage*.json
54+
coverage*.xml
55+
coverage*.info
56+
57+
# NCrunch
58+
_NCrunch_*
59+
.*crunch*.local.xml
60+
nCrunchTemp_*
61+
62+
# Publish
63+
*.publish.xml
64+
*.azurePubxml
65+
*.pubxml
66+
*.publishproj
67+
68+
# OS generated files
69+
.DS_Store
70+
.DS_Store?
71+
._*
72+
.Spotlight-V100
73+
.Trashes
74+
ehthumbs.db
75+
Thumbs.db
76+
77+
# User-specific files
78+
*.env
79+
*.env.local
80+
appsettings.Development.json
81+

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<div align="center">
2+
3+
## SharpAIKit: A Unified AI/LLM Toolkit for .NET
4+
<img src="imgs/logo.jpg" alt="SharpAIKit Logo" width="900">
5+
6+
[![.NET Version](https://img.shields.io/badge/.NET-8.0-512BD4?style=for-the-badge&logo=dotnet&logoColor=white)](https://dotnet.microsoft.com/)
7+
[![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE)
8+
[![NuGet](https://img.shields.io/badge/NuGet-v1.0.0-004880?style=for-the-badge&logo=nuget&logoColor=white)](https://www.nuget.org/)
9+
[![Build](https://img.shields.io/badge/Build-Passing-brightgreen?style=for-the-badge)](https://github.com/)
10+
11+
<br/>
12+
13+
**One API, All LLMs** — Supports OpenAI, DeepSeek, Qwen, Mistral, Yi, Groq and any OpenAI-compatible API
14+
15+
<br/>
16+
17+
---
18+
19+
### 📖 Documentation
20+
21+
<br/>
22+
23+
[![English](https://img.shields.io/badge/English-Documentation-blue?style=for-the-badge&logo=readme&logoColor=white)](README_EN.md)
24+
[![中文](https://img.shields.io/badge/中文-文档-red?style=for-the-badge&logo=readme&logoColor=white)](README_CN.md)
25+
26+
<br/>
27+
28+
---
29+
30+
</div>
31+
32+
## ⚡ Quick Example
33+
34+
```csharp
35+
using SharpAIKit.LLM;
36+
37+
// Works with ANY OpenAI-compatible API
38+
var client = LLMClientFactory.Create("api-key", "https://api.deepseek.com/v1", "deepseek-chat");
39+
40+
// Chat
41+
var response = await client.ChatAsync("Hello!");
42+
43+
// Streaming
44+
await foreach (var chunk in client.ChatStreamAsync("Tell me a story"))
45+
{
46+
Console.Write(chunk);
47+
}
48+
```
49+
50+
## 📦 Installation
51+
52+
```bash
53+
dotnet add package SharpAIKit
54+
```
55+
56+
## 🌐 Supported Providers
57+
58+
| Provider | URL |
59+
|:---------|:----|
60+
| OpenAI | `https://api.openai.com/v1` |
61+
| DeepSeek | `https://api.deepseek.com/v1` |
62+
| Qwen (Alibaba) | `https://dashscope.aliyuncs.com/compatible-mode/v1` |
63+
| Mistral | `https://api.mistral.ai/v1` |
64+
| Yi (01.AI) | `https://api.lingyiwanwu.com/v1` |
65+
| Groq | `https://api.groq.com/openai/v1` |
66+
| Moonshot (Kimi) | `https://api.moonshot.cn/v1` |
67+
| Ollama (Local) | `http://localhost:11434` |
68+
| **Any OpenAI-compatible** | Custom URL |
69+
70+
---
71+
72+
<div align="center">
73+
74+
**⭐ Star this project if it helps you!**
75+
76+
</div>

0 commit comments

Comments
 (0)