Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Llama2, Palm, Cohere, Anthropic, Replicate, VertexAI Models - using litellm #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ requests
replicate
python-dotenv
anthropic
openai
openai
litellm
47 changes: 29 additions & 18 deletions smol-podcaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datetime import datetime
import json
import openai
from litellm import completion

load_dotenv()

Expand Down Expand Up @@ -108,23 +109,35 @@ def title_suggestions(transcript):
{transcript}
"""

gpt_suggestions = openai.ChatCompletion.create(
gpt_suggestions = completion(
model="gpt-3.5-turbo-16k",
temperature=0.7,
messages=[
{"role": "user", "content": prompt}
]
)
claude_suggestions = anthropic.completions.create(

claude_suggestions = completion(
model="claude-2",
max_tokens_to_sample=3000,
max_tokens=3000,
temperature=0.7,
prompt=f"{HUMAN_PROMPT} {prompt} {AI_PROMPT}",
messages=[
{"role": "user", "content": prompt}
]
)

gpt_suggestions = gpt_suggestions.choices[0].message.content
claude_suggestions = claude_suggestions.completion
# Example usage litellm with - llama2
# Add REPLICATE_API_TOKEN to .env
# llama2_suggestions = completion(
# model="replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1",
# temperature=0.7,
# messages=[
# {"role": "user", "content": prompt}
# ]
# )

gpt_suggestions = gpt_suggestions['choices'][0]['message']['content']
claude_suggestions = claude_suggestions['choices'][0]['message']['content']

suggestions = f"GPT-3.5 16k title suggestions:\n\n{gpt_suggestions}\n\nClaude's title suggestions:\n{claude_suggestions}\n"

Expand All @@ -141,27 +154,25 @@ def tweet_suggestions(transcript):
{transcript}
"""

gpt_suggestions = openai.ChatCompletion.create(
gpt_suggestions = completion(
model="gpt-3.5-turbo-16k",
temperature=0.7,
messages=[
{"role": "user", "content": prompt}
]
)

anthropic = Anthropic(
api_key=os.environ.get("ANTHROPIC_API_KEY"),
)

claude_suggestions = anthropic.completions.create(

claude_suggestions = completion(
model="claude-2",
max_tokens_to_sample=3000,
max_tokens=3000,
temperature=0.7,
prompt=f"{HUMAN_PROMPT} {prompt} {AI_PROMPT}",
messages=[
{"role": "user", "content": prompt}
]
)

gpt_suggestions = gpt_suggestions.choices[0].message.content
claude_suggestions = claude_suggestions.completion
gpt_suggestions = gpt_suggestions['choices'][0]['message']['content']
claude_suggestions = claude_suggestions['choices'][0]['message']['content']

suggestions = f"GPT-3.5 16k tweet suggestions:\n{gpt_suggestions}\n\nClaude's tweet suggestions:\n{claude_suggestions}\n"

Expand Down