make it easy for people to use sk-litellm

This commit is contained in:
Krrish Dholakia 2023-09-18 14:08:05 -07:00
parent 633e36de42
commit e6a022ea9e
5 changed files with 69 additions and 27 deletions

View file

@ -1,6 +1,8 @@
import TokenGen from '../src/components/TokenGen.js'
# 🚨 LITELLM API (Access Claude-2/Llama2-70b/etc.)
This is an api built for the Open Interpreter community. It provides access to:
Use this if you're trying to add support for new LLMs and need access for testing:
* OpenAI models
* gpt-4
* gpt-3.5-turbo
@ -31,28 +33,30 @@ This is an api built for the Open Interpreter community. It provides access to:
Here's how to call it:
## Through LiteLLM
```python
from litellm import completion
## Step 1: Save your LiteLLM API Key
This is your unique LiteLLM API Key. Save this for later use.
<TokenGen/>
## Step 2: Test a new LLM
Now let's test if claude-2 is working in our code
```
from litellm import completion
import os
## set ENV variables
os.environ["OPENAI_API_KEY"] = "litellm-api-key"
messages = [{ "content": "Hello, how are you?","role": "user"}]
# set env var
os.environ["ANTHROPIC_API_KEY"] = "sk-litellm-1234" # 👈 replace with your unique key
response = completion(
model="command-nightly",
messages=[{ "content": "Hello, how are you?","role": "user"}],
api_base="https://proxy.litellm.ai",
custom_llm_provider="openai",
temperature=0.2,
max_tokens=80,
)
print(response)
messages = [{"role": "user", "content": "Hey, how's it going?"}]
response = completion(model="claude-2", messages=messages)
print(response)
```
## In CodeInterpreter
## For OpenInterpreter
This was initially built for the Open Interpreter community. If you're trying to use this feature in there, here's how you can do it:
**Note**: You will need to clone and modify the Github repo, until [this PR is merged.](https://github.com/KillianLucas/open-interpreter/pull/288)
```

View file

@ -18,7 +18,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sharp": "^0.32.5",
"uuid": "^9.0.0"
"uuid": "^9.0.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.4.1"
@ -12823,9 +12823,13 @@
}
},
"node_modules/uuid": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"bin": {
"uuid": "dist/bin/uuid"
}

View file

@ -24,7 +24,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sharp": "^0.32.5",
"uuid": "^9.0.0"
"uuid": "^9.0.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.4.1"

View file

@ -0,0 +1,34 @@
import React, { useState, useEffect } from 'react';
import {v4 as uuidv4} from 'uuid';
const CodeBlock = ({ token }) => {
const codeWithToken = `${token}`;
return (
<pre>
{token ? codeWithToken : ""}
</pre>
);
};
const TokenGen = () => {
const [token, setToken] = useState(null);
useEffect(() => {
const generateToken = () => {
// Generate a special uuid/token "sk-litellm-<uuid>"
const newToken = `sk-litellm-${uuidv4()}`;
setToken(newToken);
};
generateToken();
}, []);
return (
<div>
<CodeBlock token={token} />
</div>
);
};
export default TokenGen;

View file

@ -7954,10 +7954,10 @@ uuid@^8.3.2:
resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
uuid@^9.0.0:
version "9.0.0"
resolved "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==
uuid@^9.0.1:
version "9.0.1"
resolved "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz"
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==
value-equal@^1.0.1:
version "1.0.1"