Skip to content

Commit 764c66a

Browse files
committed
Create README.md
1 parent 38915dc commit 764c66a

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

agixt-sdk/README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# AGiXT Rust SDK
2+
3+
[![GitHub](https://img.shields.io/badge/GitHub-Sponsor%20Josh%20XT-blue?logo=github&style=plastic)](https://github.com/sponsors/Josh-XT) [![PayPal](https://img.shields.io/badge/PayPal-Sponsor%20Josh%20XT-blue.svg?logo=paypal&style=plastic)](https://paypal.me/joshxt) [![Ko-Fi](https://img.shields.io/badge/Kofi-Sponsor%20Josh%20XT-blue.svg?logo=kofi&style=plastic)](https://ko-fi.com/joshxt)
4+
5+
[![GitHub](https://img.shields.io/badge/GitHub-AGiXT%20Core-blue?logo=github&style=plastic)](https://github.com/Josh-XT/AGiXT) [![GitHub](https://img.shields.io/badge/GitHub-AGiXT%20Hub-blue?logo=github&style=plastic)](https://github.com/AGiXT/hub) [![GitHub](https://img.shields.io/badge/GitHub-AGiXT%20NextJS%20Web%20UI-blue?logo=github&style=plastic)](https://github.com/AGiXT/nextjs) [![GitHub](https://img.shields.io/badge/GitHub-AGiXT%20Streamlit%20Web%20UI-blue?logo=github&style=plastic)](https://github.com/AGiXT/streamlit)
6+
7+
[![GitHub](https://img.shields.io/badge/GitHub-AGiXT%20Python%20SDK-blue?logo=github&style=plastic)](https://github.com/AGiXT/python-sdk) [![pypi](https://img.shields.io/badge/pypi-AGiXT%20Python%20SDK-blue?logo=pypi&style=plastic)](https://pypi.org/project/agixtsdk/)
8+
9+
[![GitHub](https://img.shields.io/badge/GitHub-AGiXT%20TypeScript%20SDK-blue?logo=github&style=plastic)](https://github.com/AGiXT/typescript-sdk) [![npm](https://img.shields.io/badge/npm-AGiXT%20TypeScript%20SDK-blue?logo=npm&style=plastic)](https://www.npmjs.com/package/agixt)
10+
11+
[![GitHub](https://img.shields.io/badge/GitHub-AGiXT%20Dart%20SDK-blue?logo=github&style=plastic)](https://github.com/AGiXT/dart-sdk)
12+
13+
[![Discord](https://img.shields.io/discord/1097720481970397356?label=Discord&logo=discord&logoColor=white&style=plastic&color=5865f2)](https://discord.gg/d3TkHRZcjD)
14+
[![Twitter](https://img.shields.io/badge/Twitter-Follow_@Josh_XT-blue?logo=twitter&style=plastic)](https://twitter.com/Josh_XT)
15+
16+
[![Logo](https://josh-xt.github.io/AGiXT/images/AGiXT-gradient-flat.svg)](https://josh-xt.github.io/AGiXT/)
17+
18+
This is the official Rust SDK for [AGiXT](https://github.com/AGiXT/python-sdk), providing a type-safe way to interact with the AGiXT API.
19+
20+
## Features
21+
22+
- Full API coverage for AGiXT
23+
- Async/await support using Tokio
24+
- Type-safe request and response handling
25+
- Comprehensive error handling
26+
- Built-in support for authentication and session management
27+
28+
## Installation
29+
30+
Add this to your `Cargo.toml`:
31+
32+
```toml
33+
[dependencies]
34+
agixt-sdk = "0.1.0"
35+
```
36+
37+
## Quick Start
38+
39+
```rust
40+
use agixt_sdk::AGiXTSDK;
41+
42+
#[tokio::main]
43+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
44+
// Create a new SDK instance
45+
let client = AGiXTSDK::new(
46+
Some("http://localhost:7437".to_string()),
47+
Some("your-api-key".to_string()),
48+
false,
49+
);
50+
51+
// Get list of available providers
52+
let providers = client.get_providers().await?;
53+
println!("Available providers: {:?}", providers);
54+
55+
// Create a new agent
56+
let agent_name = "my_agent";
57+
client.add_agent(agent_name, None, None, None).await?;
58+
59+
// Start a new conversation
60+
let conversation = client.new_conversation(agent_name, "test_conversation", None).await?;
61+
println!("Created conversation: {:?}", conversation);
62+
63+
Ok(())
64+
}
65+
```
66+
67+
## Authentication
68+
69+
```rust
70+
use agixt_sdk::AGiXTSDK;
71+
72+
#[tokio::main]
73+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
74+
let client = AGiXTSDK::new(None, None, false);
75+
76+
// Register a new user
77+
let otp_uri = client.register_user(
78+
"user@example.com",
79+
"John",
80+
"Doe"
81+
).await?;
82+
println!("Registration successful. OTP URI: {}", otp_uri);
83+
84+
// Login with email and OTP
85+
if let Some(token) = client.login("user@example.com", "123456").await? {
86+
println!("Login successful! Token: {}", token);
87+
}
88+
89+
Ok(())
90+
}
91+
```
92+
93+
## Core Features
94+
95+
### Providers
96+
97+
```rust
98+
// Get all available providers
99+
let providers = client.get_providers().await?;
100+
101+
// Get providers for a specific service
102+
let chat_providers = client.get_providers_by_service("chat").await?;
103+
104+
// Get provider settings
105+
let settings = client.get_provider_settings("gpt4free").await?;
106+
```
107+
108+
### Agents
109+
110+
```rust
111+
// Create a new agent
112+
client.add_agent("my_agent", None, None, None).await?;
113+
114+
// Get agent configuration
115+
let config = client.get_agent_config("my_agent").await?;
116+
117+
// Update agent settings
118+
use std::collections::HashMap;
119+
let mut settings = HashMap::new();
120+
settings.insert("setting_key".to_string(), serde_json::json!("value"));
121+
client.update_agent_settings("my_agent", settings).await?;
122+
```
123+
124+
### Conversations
125+
126+
```rust
127+
// Create a new conversation
128+
let conversation = client.new_conversation("my_agent", "test_conv", None).await?;
129+
130+
// Add a message to the conversation
131+
client.new_conversation_message("user", "Hello!", "test_conv").await?;
132+
133+
// Get conversation history
134+
let history = client.get_conversation("my_agent", "test_conv", Some(10), Some(1)).await?;
135+
```
136+
137+
## Error Handling
138+
139+
The SDK uses a custom error type that covers various error cases:
140+
141+
```rust
142+
pub enum Error {
143+
RequestError(reqwest::Error),
144+
JsonError(serde_json::Error),
145+
ApiError { status: u16, message: String },
146+
AuthError(String),
147+
InvalidInput(String),
148+
Other(String),
149+
}
150+
```
151+
152+
All methods return a `Result<T, Error>` type, allowing for proper error handling:
153+
154+
```rust
155+
match client.get_providers().await {
156+
Ok(providers) => println!("Providers: {:?}", providers),
157+
Err(e) => eprintln!("Error: {}", e),
158+
}
159+
```
160+
161+
## Contributing
162+
163+
Contributions are welcome! Please feel free to submit a Pull Request.
164+
165+
## License
166+
167+
This project is licensed under the MIT License - see the LICENSE file for details.

0 commit comments

Comments
 (0)