Skip to content
Open
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
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GOOGLE_APPLICATION_CREDENTIALS=./google-adc
GOOGLE_REGION=
GOOGLE_PROJECT_ID=

# Hugging Face token
# Hugging Face token
HF_TOKEN=

# Fireworks
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/black.yml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Ruff

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
1 change: 0 additions & 1 deletion .github/workflows/run_pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ jobs:
poetry install --all-extras --with test
- name: Test with pytest
run: poetry run pytest -m "not integration"

24 changes: 14 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
repos:
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.12
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.4
hooks:
- id: ruff-check
args: [ --config=ruff.toml, --fix ]
- id: ruff-format
args: [ --config=ruff.toml ]
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ you to investigate carefully, collect information and describe the issue in deta
complete the following steps in advance to help us fix any potential bug as fast as possible.

- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment
components/versions (Make sure that you have read the [documentation](https://github.com/andrewyng/aisuite/blob/main/README.md).
If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having,
Expand Down Expand Up @@ -99,7 +99,7 @@ We use GitHub issues to track bugs and errors. If you run into an issue with the
Once it's filed:

- The project team will label the issue accordingly.
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction
steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the
issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
[![PyPI](https://img.shields.io/pypi/v/aisuite)](https://pypi.org/project/aisuite/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

`aisuite` is a lightweight Python library that provides a **unified API for working with multiple Generative AI providers**.
It offers a consistent interface for models from *OpenAI, Anthropic, Google, Hugging Face, AWS, Cohere, Mistral, Ollama*, and others—abstracting away SDK differences, authentication details, and parameter variations.
`aisuite` is a lightweight Python library that provides a **unified API for working with multiple Generative AI providers**.
It offers a consistent interface for models from *OpenAI, Anthropic, Google, Hugging Face, AWS, Cohere, Mistral, Ollama*, and others—abstracting away SDK differences, authentication details, and parameter variations.
Its design is modeled after OpenAI’s API style, making it instantly familiar and easy to adopt.

`aisuite` lets developers build and **run LLM-based or agentic applications across providers** with minimal setup.
While it’s not a full-blown agents framework, it includes simple abstractions for creating standalone, lightweight agents.
`aisuite` lets developers build and **run LLM-based or agentic applications across providers** with minimal setup.
While it’s not a full-blown agents framework, it includes simple abstractions for creating standalone, lightweight agents.
It’s designed for low learning curve — so you can focus on building AI systems, not integrating APIs.

---
Expand Down Expand Up @@ -132,7 +132,7 @@ You can pass tools in the OpenAI tool format:
```python
def will_it_rain(location: str, time_of_day: str):
"""Check if it will rain in a location at a given time today.

Args:
location (str): Name of the city
time_of_day (str): Time of the day in HH:MM format.
Expand Down Expand Up @@ -175,7 +175,7 @@ When `max_turns` is specified, you can pass a list of callable Python functions
```python
def will_it_rain(location: str, time_of_day: str):
"""Check if it will rain in a location at a given time today.

Args:
location (str): Name of the city
time_of_day (str): Time of the day in HH:MM format.
Expand Down
12 changes: 6 additions & 6 deletions aisuite-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ npm install aisuite
import { Client } from 'aisuite';

const client = new Client({
openai: {
apiKey: process.env.OPENAI_API_KEY,
openai: {
apiKey: process.env.OPENAI_API_KEY,
},
anthropic: { apiKey: process.env.ANTHROPIC_API_KEY },
deepgram: { apiKey: process.env.DEEPGRAM_API_KEY },
Expand Down Expand Up @@ -152,8 +152,8 @@ try {
```typescript
// Initialize client with audio support for OpenAI
const client = new Client({
openai: {
apiKey: process.env.OPENAI_API_KEY,
openai: {
apiKey: process.env.OPENAI_API_KEY,
},
deepgram: { apiKey: process.env.DEEPGRAM_API_KEY }
});
Expand Down Expand Up @@ -212,7 +212,7 @@ const client = new Client({
openai?: {
apiKey: string;
baseURL?: string;
organization?: string;
organization?: string;
},
anthropic?: {
apiKey: string;
Expand Down Expand Up @@ -254,7 +254,7 @@ interface TranscriptionRequest {
timestamps?: boolean; // Include word-level timestamps
[key: string]: any; // Additional provider-specific parameters:
// For OpenAI: See https://platform.openai.com/docs/api-reference/audio/createTranscription
// For Deepgram: See https://developers.deepgram.com/reference/speech-to-text-api/listen
// For Deepgram: See https://developers.deepgram.com/reference/speech-to-text-api/listen
}
```

Expand Down
2 changes: 1 addition & 1 deletion aisuite-js/examples/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
OPENAI_API_KEY=your-openai-api-key-here
ANTHROPIC_API_KEY=your-anthropic-api-key-here
GROQ_API_KEY=your-groq-api-key-here
MISTRAL_API_KEY=your-mistral-api-key-here
MISTRAL_API_KEY=your-mistral-api-key-here
2 changes: 1 addition & 1 deletion aisuite-js/examples/basic-usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ async function main() {
}

// Run the examples
main().catch(console.error);
main().catch(console.error);
2 changes: 1 addition & 1 deletion aisuite-js/examples/chat-app/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ module.exports = {
{ allowConstantExport: true },
],
},
}
}
2 changes: 1 addition & 1 deletion aisuite-js/examples/chat-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ dist-ssr
.env.local
.env.development.local
.env.test.local
.env.production.local
.env.production.local
4 changes: 2 additions & 2 deletions aisuite-js/examples/chat-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ A modern React TypeScript chat application built with AISuite, allowing you to c

## Prerequisites

- Node.js 18+
- Node.js 18+
- npm or yarn
- API keys for the AI providers you want to use:
- OpenAI API key
Expand Down Expand Up @@ -207,4 +207,4 @@ For issues and questions:

- API keys are stored in localStorage (client-side only)
- No API keys are sent to any server except the AI providers
- Consider using environment variables for production deployments
- Consider using environment variables for production deployments
2 changes: 1 addition & 1 deletion aisuite-js/examples/chat-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions aisuite-js/examples/chat-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dom": "^18.2.0",
"lucide-react": "^0.263.1",
"clsx": "^2.0.0",
"tailwind-merge": "^1.14.0"
Expand All @@ -31,4 +31,4 @@
"typescript": "^5.0.2",
"vite": "^4.4.5"
}
}
}
2 changes: 1 addition & 1 deletion aisuite-js/examples/chat-app/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export default {
tailwindcss: {},
autoprefixer: {},
},
}
}
12 changes: 6 additions & 6 deletions aisuite-js/examples/chat-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ function App() {
// Get all available providers (show all by default)
const allProviders = ['openai', 'anthropic', 'groq', 'mistral'];
const availableProviders = allProviders;

// Get configured providers (those with API keys)
const configuredProviders = Object.keys(apiConfig).filter(provider =>
const configuredProviders = Object.keys(apiConfig).filter(provider =>
apiConfig[provider as keyof AISuiteConfig]?.apiKey
);

// Get models for the selected provider
const availableModels = selectedProvider
const availableModels = selectedProvider
? configuredLLMs.filter(model => model.provider === selectedProvider)
: [];

Expand Down Expand Up @@ -261,8 +261,8 @@ function App() {

{/* Chat Containers */}
{selectedProvider && selectedModel1 && (
<div className="grid grid-cols-1 gap-6" style={{
gridTemplateColumns: useComparisonMode && selectedModel2 ? '1fr 1fr' : '1fr'
<div className="grid grid-cols-1 gap-6" style={{
gridTemplateColumns: useComparisonMode && selectedModel2 ? '1fr 1fr' : '1fr'
}}>
<div className="border rounded-lg bg-card h-[500px] flex flex-col">
<div className="border-b p-4">
Expand Down Expand Up @@ -330,4 +330,4 @@ function App() {
);
}

export default App;
export default App;
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ export const ApiKeyModal: React.FC<ApiKeyModalProps> = ({
</div>
</div>
);
};
};
20 changes: 10 additions & 10 deletions aisuite-js/examples/chat-app/src/components/ChatContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ interface ChatContainerProps {
isLoading?: boolean;
}

export const ChatContainer: React.FC<ChatContainerProps> = ({
messages,
modelName,
isLoading = false
export const ChatContainer: React.FC<ChatContainerProps> = ({
messages,
modelName,
isLoading = false
}) => {
const messagesEndRef = useRef<HTMLDivElement>(null);

Expand All @@ -36,14 +36,14 @@ export const ChatContainer: React.FC<ChatContainerProps> = ({
</div>
) : (
messages.map((message, index) => (
<ChatMessage
key={index}
message={message}
<ChatMessage
key={index}
message={message}
modelName={modelName}
/>
))
)}

{isLoading && (
<div className="flex gap-3 p-4 justify-start">
<div className="flex-shrink-0 w-8 h-8 bg-primary rounded-full flex items-center justify-center">
Expand All @@ -66,10 +66,10 @@ export const ChatContainer: React.FC<ChatContainerProps> = ({
</div>
</div>
)}

<div ref={messagesEndRef} />
</div>
</div>
</div>
);
};
};
8 changes: 4 additions & 4 deletions aisuite-js/examples/chat-app/src/components/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
style={{ minHeight: '60px', maxHeight: '120px' }}
/>
</div>

<div className="flex flex-col gap-2">
<button
onClick={handleSend}
Expand All @@ -56,7 +56,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
>
<Send className="w-4 h-4" />
</button>

<button
onClick={onResetChat}
disabled={isLoading}
Expand All @@ -67,7 +67,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
</button>
</div>
</div>

{isLoading && (
<div className="mt-2 text-sm text-muted-foreground flex items-center gap-2">
<div className="w-4 h-4 border-2 border-muted-foreground border-t-transparent rounded-full animate-spin" />
Expand All @@ -76,4 +76,4 @@ export const ChatInput: React.FC<ChatInputProps> = ({
)}
</div>
);
};
};
8 changes: 4 additions & 4 deletions aisuite-js/examples/chat-app/src/components/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export const ChatMessage: React.FC<ChatMessageProps> = ({ message, modelName })
<Bot className="w-4 h-4 text-primary-foreground" />
</div>
)}

<div className={`max-w-[80%] ${isUser ? 'order-first' : ''}`}>
<div className={`rounded-lg p-3 ${
isUser
? 'bg-primary text-primary-foreground'
isUser
? 'bg-primary text-primary-foreground'
: 'bg-muted text-foreground'
}`}>
<div className="text-sm font-medium mb-1 opacity-70">
Expand All @@ -48,4 +48,4 @@ export const ChatMessage: React.FC<ChatMessageProps> = ({ message, modelName })
)}
</div>
);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export const ModelSelector: React.FC<ModelSelectorProps> = ({
</select>
</div>
);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ export const ProviderSelector: React.FC<ProviderSelectorProps> = ({
</select>
</div>
);
};
};
2 changes: 1 addition & 1 deletion aisuite-js/examples/chat-app/src/config/llm-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ export const getLLMConfigByName = (name: string): LLMConfig | undefined => {

export const getLLMConfigByProviderAndModel = (provider: string, model: string): LLMConfig | undefined => {
return configuredLLMs.find(llm => llm.provider === provider && llm.model === model);
};
};
Loading