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

adding support for claude, azure, cohere, and replicate #34

Open
wants to merge 3 commits 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
349 changes: 348 additions & 1 deletion poetry.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "readmeai"
version = "0.4.04"
version = "0.4.05"
description = "🚀 Generate beautiful README.md files from the terminal. Powered by OpenAI's GPT LLMs 💫"
authors = ["Eli <0x.eli.64s@gmail.com>"]
license = "MIT"
Expand Down Expand Up @@ -57,6 +57,8 @@ tornado = "^6.3.3"
asyncio = "^3.4.3"
aiohttp = "^3.8.5"
click = "^8.1.7"
litellm = "^0.1.817"
jinja2 = "^3.1.2"


[tool.poetry.dev-dependencies]
Expand Down
354 changes: 354 additions & 0 deletions readme-ai.md

Large diffs are not rendered by default.

24 changes: 8 additions & 16 deletions readmeai/core/model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""OpenAI API handler, generates text for the README.md file."""

import asyncio
import time
import time, os
from typing import Dict, List, Tuple

import httpx
import openai
from litellm import acompletion
from cachetools import TTLCache
from tenacity import (
RetryError,
Expand Down Expand Up @@ -176,25 +177,16 @@ async def generate_text(
"""
try:
async with self.rate_limit_semaphore:
response = await self.http_client.post(
self.endpoint,
headers={"Authorization": f"Bearer {openai.api_key}"},
json={
"messages": [
{
api_key = os.getenv("LLM_API_KEY") or openai.api_key
messages = [{
"role": "system",
"content": "You're a brilliant Tech Lead.",
},
{"role": "user", "content": prompt},
],
"model": self.model,
"temperature": self.temperature,
"max_tokens": tokens,
},
)
response.raise_for_status()
data = response.json()
summary = data["choices"][0]["message"]["content"]
]
print(f"model: {self.model}")
response = await acompletion(model=self.model, messages=messages, temperature=self.temperature, max_tokens=tokens, api_key=api_key)
summary = response["choices"][0]["message"]["content"]
summary = format_sentence(summary) if index != 3 else summary

self.logger.info(
Expand Down
Empty file added readmeai/md_builder/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion readmeai/settings/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[api]
endpoint = "https://api.openai.com/v1/chat/completions"
encoding = "cl100k_base"
model = "gpt-3.5-turbo"
model = "claude-instant-1"
rate_limit = 5
tokens = 650
tokens_max = 3800
Expand Down
2 changes: 1 addition & 1 deletion readmeai/utils/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_user_repository_name(url_or_path) -> (str, str):
"""

if os.path.exists(url_or_path):
return os.path.basename(url_or_path), "local"
return os.path.basename(url_or_path)

patterns = {
"github": r"https?://github.com/([^/]+)/([^/]+)",
Expand Down