gpt4free/g4f/Provider/Providers/You.py

23 行
619 B
Python
Raw 通常表示 履歴

2023-05-15 09:22:55 +09:00
import os
import json
import time
import subprocess
2023-06-05 08:47:01 +09:00
from ...typing import sha256, Dict, get_type_hints
2023-05-17 00:57:16 +09:00
2023-05-15 09:22:55 +09:00
url = 'https://you.com'
model = 'gpt-3.5-turbo'
2023-06-05 08:47:01 +09:00
supports_stream = True
2023-05-15 09:22:55 +09:00
2023-06-05 08:47:01 +09:00
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
2023-05-15 09:22:55 +09:00
path = os.path.dirname(os.path.realpath(__file__))
config = json.dumps({
'messages': messages}, separators=(',', ':'))
cmd = ['python3', f'{path}/helpers/you.py', config]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in iter(p.stdout.readline, b''):
2023-06-05 08:47:01 +09:00
yield line.decode('utf-8') #[:-1]