Update app110.py
Browse files
app110.py
CHANGED
@@ -20,31 +20,32 @@ warnings.filterwarnings('ignore')
|
|
20 |
os.getenv("OAUTH_CLIENT_ID")
|
21 |
|
22 |
|
23 |
-
#
|
24 |
-
|
25 |
-
# client = OpenAI(
|
26 |
-
# base_url="https://api-inference.huggingface.co/v1",
|
27 |
-
# api_key=os.environ.get('TOKEN2') # Hugging Face API token
|
28 |
-
# )
|
29 |
-
#####
|
30 |
-
from openai import OpenAI
|
31 |
-
|
32 |
client = OpenAI(
|
33 |
-
base_url="https://
|
34 |
-
#api_key=
|
35 |
-
api_key=os.environ.get('
|
36 |
-
)
|
37 |
-
#meta-llama/Meta-Llama-3-8B-Instruct
|
38 |
-
completion = client.chat.completions.create(
|
39 |
-
#model="meta-llama/Meta-Llama-3-8B-Instruct-Turbo",
|
40 |
-
model="meta-llama/Meta-Llama-3-8B-Instruct",
|
41 |
-
messages=[
|
42 |
-
{
|
43 |
-
"role": "user",
|
44 |
-
"content": "What is the capital of France?"
|
45 |
-
}
|
46 |
-
],
|
47 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
print(completion.choices[0].message)
|
50 |
#####
|
|
|
20 |
os.getenv("OAUTH_CLIENT_ID")
|
21 |
|
22 |
|
23 |
+
# Load environment variables and initialize the OpenAI client to use Hugging Face Inference API.
|
24 |
+
load_dotenv()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
client = OpenAI(
|
26 |
+
base_url="https://api-inference.huggingface.co/v1",
|
27 |
+
#api_key=os.environ.get('TOKEN2') # Hugging Face API token
|
28 |
+
api_key=os.environ.get('LLM')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
)
|
30 |
+
#####
|
31 |
+
# from openai import OpenAI
|
32 |
+
|
33 |
+
# client = OpenAI(
|
34 |
+
# base_url="https://router.huggingface.co/together/v1",
|
35 |
+
# #api_key="hf_XXXXX",
|
36 |
+
# api_key=os.environ.get('TOKEN2'), # Hugging Face API token
|
37 |
+
# )
|
38 |
+
# #meta-llama/Meta-Llama-3-8B-Instruct
|
39 |
+
# completion = client.chat.completions.create(
|
40 |
+
# #model="meta-llama/Meta-Llama-3-8B-Instruct-Turbo",
|
41 |
+
# model="meta-llama/Meta-Llama-3-8B-Instruct",
|
42 |
+
# messages=[
|
43 |
+
# {
|
44 |
+
# "role": "user",
|
45 |
+
# "content": "What is the capital of France?"
|
46 |
+
# }
|
47 |
+
# ],
|
48 |
+
# )
|
49 |
|
50 |
print(completion.choices[0].message)
|
51 |
#####
|