diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -11,7 +11,7 @@ pip install -U g4f ``` ## New features -* Telegram Channel: [t.me/g4f_channel](https://t.me/g4f_channel) +* Telegram Channel: [t.me/g4f_channel](https://telegram.me/g4f_channel) * g4f documentation (unfinished): [g4f.mintlify.app](https://g4f.mintlify.app) | Contribute to the docs via: [github.com/xtekky/gpt4free-docs](https://github.com/xtekky/gpt4free-docs) ## Table of Contents @@ -331,9 +331,12 @@ python -m g4f.api ```py import openai -openai.api_key = " Leave Empty if you don't use embeddings, otherwise your Hugging Face token" -openai.api_base = "http://localhost:1337/v1" +# Set your Hugging Face token as the API key if you use embeddings +# If you don't use embeddings, leave it empty +openai.api_key = "YOUR_HUGGING_FACE_TOKEN" # Replace with your actual token +# Set the API base URL if needed, e.g., for a local development environment +openai.api_base = "http://localhost:1337/v1" def main(): chat_completion = openai.ChatCompletion.create( @@ -343,18 +346,18 @@ def main(): ) if isinstance(chat_completion, dict): - # not stream + # Not streaming print(chat_completion.choices[0].message.content) else: - # stream + # Streaming for token in chat_completion: content = token["choices"][0]["delta"].get("content") - if content != None: + if content is not None: print(content, end="", flush=True) - -if __name__ == "__main__": +if __name__ == "__main": main() + ``` ## Models @@ -543,7 +546,7 @@ Call in your terminal the "create_provider" script: python etc/tool/create_provider.py ``` 1. Enter your name for the new provider. -2. Copy and paste a cURL command from your browser developer tools. +2. Copy and paste the `URL` command from your browser developer tools. 3. Let the AI create the provider for you. 4. Customize the provider according to your needs. |