Skip to content

Commit 67393eb

Browse files
henrycunhCyrus Nouroozi
andauthored
feat: add Pydantic V2 and OpenRouter.ai support (#8)
Co-authored-by: Cyrus Nouroozi <cyrus@edendaolab.com>
1 parent e92ee3a commit 67393eb

File tree

9 files changed

+914
-416
lines changed

9 files changed

+914
-416
lines changed

README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ cursive = Cursive()
7979
def add(a: float, b: float):
8080
"""
8181
Adds two numbers.
82-
82+
8383
a: The first number.
8484
b: The second number.
8585
"""
@@ -101,7 +101,7 @@ The functions' result will automatically be fed into the conversation and anothe
101101
def create_character(name: str, age: str):
102102
"""
103103
Creates a character.
104-
104+
105105
name: The name of the character.
106106
age: The age of the character.
107107
"""
@@ -156,7 +156,7 @@ cursive = Cursive(
156156
expand={
157157
'enable': True,
158158
'defaults_to': 'gpt-3.5-turbo-16k',
159-
'model_mapping': {
159+
'resolve_model': {
160160
'gpt-3.5-turbo': 'gpt-3.5-turbo-16k',
161161
'gpt-4': 'claude-2',
162162
},
@@ -180,6 +180,34 @@ You can pass your OpenAI API key to `Cursive`'s constructor, or set the `OPENAI_
180180
- `claude-instant-1.2`
181181
- Any other model version
182182

183+
#### OpenRouter
184+
185+
OpenRouter is a service that gives you access to leading language models in an OpenAI-compatible API, including function calling!
186+
187+
- `anthropic/claude-instant-1.2`
188+
- `anthropic/claude-2`
189+
- `openai/gpt-4-32k`
190+
- `google/palm-2-codechat-bison`
191+
- `nousresearch/nous-hermes-llama2-13b`
192+
- Any model version from https://openrouter.ai/docs#models
193+
194+
###### Credentials
195+
196+
```python
197+
import openai
198+
import requests
199+
200+
openai.api_key = "sk-or-..."
201+
openai.api_base = "https://openrouter.ai/api/v1"
202+
openai.requestssession = requests.Session()
203+
openai.requestssession.headers.update({"HTTP-Referer": "https://appurl.com", "X-Title": "YOUR_APP_NAME"})
204+
205+
from cursive import Cursive
206+
207+
cursive = Cursive()
208+
cursive.ask(prompt="What is the meaning of life?", model="anthropic/claude-instant-1.2")
209+
```
210+
183211
###### Credentials
184212
You can pass your Anthropic API key to `Cursive`'s constructor, or set the `ANTHROPIC_API_KEY` environment variable.
185213

@@ -208,6 +236,6 @@ You can pass your Replicate API key to `Cursive`'s constructor, or set the `REPL
208236
### vendor support
209237
- [x] Anthropic
210238
- [x] Cohere
211-
- [x] Replicate
239+
- [x] Replicate
212240
- [ ] Azure OpenAI models
213-
- [ ] Huggingface
241+
- [ ] Huggingface

0 commit comments

Comments
 (0)