summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAryan4884 <116114086+Aryan4884@users.noreply.github.com>2023-10-26 17:35:49 +0200
committerHeiner Lohaus <heiner@lohaus.eu>2023-10-26 21:37:18 +0200
commit92a31d828125f708c615c377bb9732ff48706c84 (patch)
treed9f2b8e2b890f23864177988037b8d8010e4aed8
parentUpdate LEGAL_NOTICE.md (diff)
downloadgpt4free-92a31d828125f708c615c377bb9732ff48706c84.tar
gpt4free-92a31d828125f708c615c377bb9732ff48706c84.tar.gz
gpt4free-92a31d828125f708c615c377bb9732ff48706c84.tar.bz2
gpt4free-92a31d828125f708c615c377bb9732ff48706c84.tar.lz
gpt4free-92a31d828125f708c615c377bb9732ff48706c84.tar.xz
gpt4free-92a31d828125f708c615c377bb9732ff48706c84.tar.zst
gpt4free-92a31d828125f708c615c377bb9732ff48706c84.zip
Diffstat (limited to '')
-rw-r--r--README.md17
1 files changed, 10 insertions, 7 deletions
diff --git a/README.md b/README.md
index 5a86b786..e3906250 100644
--- a/README.md
+++ b/README.md
@@ -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