Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Updates ChimeraGPT API
Browse files Browse the repository at this point in the history
  • Loading branch information
ramon-victor committed Jul 28, 2023
1 parent deb7f0a commit 59f6ed0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
12 changes: 0 additions & 12 deletions client/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,10 @@
<optgroup label="GPT">
<option value="gpt-3.5-turbo">GPT-3.5-turbo</option>
<option value="gpt-3.5-turbo-0301">GPT-3.5-turbo-0301</option>
<option value="gpt-3.5-turbo-poe">GPT-3.5-turbo-poe</option>
<option value="gpt-3.5-turbo-16k">GPT-3.5-turbo-16k</option>
<option value="gpt-3.5-turbo-16k-poe">GPT-3.5-turbo-16k-poe</option>
<option value="gpt-4">GPT-4</option>
<option value="gpt-4-0314">GPT-4-0314</option>
<option value="gpt-4-poe">GPT-4-poe</option>
<option value="gpt-4-32k">GPT-4-32k</option>
<option value="gpt-4-32k-poe">GPT-4-32k-poe</option>
</optgroup>
<optgroup label="SAGE">
<option value="sage">Sage</option>
</optgroup>
<optgroup label="CLAUDE">
<option value="claude-instant">Claude-Instant</option>
<option value="claude-2-100k">Claude-2-100k</option>
<option value="claude-instant-100k">Claude-Instant-100k</option>
</optgroup>
<optgroup label="LLAMA">
<option value="llama-2-7b-chat">llama-2-7b-chat</option>
Expand Down
25 changes: 8 additions & 17 deletions g4f/Provider/Providers/Chimera.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,19 @@
model = [
'gpt-3.5-turbo',
'gpt-3.5-turbo-0301',
'gpt-3.5-turbo-poe',
'gpt-3.5-turbo-openai',
'gpt-3.5-turbo-16k',
'gpt-3.5-turbo-16k-openai',
'gpt-3.5-turbo-16k-poe',
'gpt-4',
'gpt-4-0314',
'gpt-4-poe',
'gpt-4-32k',
'gpt-4-32k-poe',
'claude_instant',
'claude-instant-100k',
'claude-2-100k',
'llama-2-7b-chat'
'llama-2-7b-chat',
'llama-2-13b-chat',
'llama-2-70b-chat',
'sage'
]

supports_stream = True
needs_auth = False


def _create_completion(api_key: str, model: str, messages: list, stream: bool, **kwargs):
def _create_completion(model: str, messages: list, stream: bool, api_key: str = None, **kwargs):

openai.api_key = api_key if api_key else api_key_env

Expand All @@ -47,9 +36,12 @@ def _create_completion(api_key: str, model: str, messages: list, stream: bool, *
stream=stream
)

for chunk in response:
yield chunk.choices[0].delta.get("content", "")

if (stream):
for chunk in response:
yield chunk.choices[0].delta.get("content", "")
else:
yield response.choices[0].message.get("content", "")

except openai.error.APIError as e:
detail_pattern = re.compile(r'{"detail":"(.*?)"}')
match = detail_pattern.search(e.user_message)
Expand All @@ -62,7 +54,6 @@ def _create_completion(api_key: str, model: str, messages: list, stream: bool, *
yield e.user_message



params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
'(%s)' % ', '.join(
[f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])

0 comments on commit 59f6ed0

Please sign in to comment.