このコミットが含まれているのは:
abc 2023-05-13 11:06:04 +01:00
コミット a3e3362858
4個のファイルの変更58行の追加33行の削除

ファイルの表示

@ -1,4 +1,60 @@
### `g4f.Providers` class
g4f-v2 beta !!, only for developers !!
### interference opneai-proxy api (use with openai python package)
###### run server: `python3 ./interference/app.py`
```
import openai
openai.api_key = ''
openai.api_base = 'http://127.0.0.1:1337'
chat_completion = openai.ChatCompletion.create(stream=True,
model='gpt-3.5-turbo', messages=[{'role': 'user', 'content': 'write a poem about a tree'}])
#print(chat_completion.choices[0].message.content)
for token in chat_completion:
content = token['choices'][0]['delta'].get('content')
if content != None:
print(content)
```
### simple usage:
```
import g4f
print(g4f.Providers.Ails.params) # supported args
# Automatic selection of provider
# streamed completion
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', messages=[
{"role": "user", "content": "Hello world"}], stream=True)
for message in response:
print(message)
# normal response
response = g4f.ChatCompletion.create(model=g4f.Models.gpt_4, prompt='hi') # alterative model setting
print(response)
# Set with provider
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Providers.Phind, messages=[
{"role": "user", "content": "Hello world"}], stream=True)
for message in response:
print(message)
```
### Dev
(more instructions soon)
the `g4f.Providers`class
default:

ファイルの表示

@ -20,7 +20,7 @@ class website:
self.config = {
'host': '0.0.0.0',
'port': 5432 if os.name == 'nt' else 1447,
'port': 1337,
'debug': True
}

ファイルの表示

@ -1,15 +0,0 @@
import openai
openai.api_key = ''
openai.api_base = 'paste_address_here'
chat_completion = openai.ChatCompletion.create(stream=True,
model='gpt-3.5-turbo', messages=[{'role': 'user', 'content': 'write a poem about a tree'}])
#print(chat_completion.choices[0].message.content)
for token in chat_completion:
content = token['choices'][0]['delta'].get('content')
if content != None:
print(content)

ファイルの表示

@ -1,16 +0,0 @@
import g4f
# print(g4f.Providers.Ails.params)
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Providers.Phind, messages=[
{"role": "user", "content": "Hello world"}], stream=True)
for message in response:
print(message)
# response = g4f.ChatCompletion.create(model=g4f.Models.gpt_35_turbo,
# provider=g4f.Providers.Ails, prompt='hi')
# print(response)