mirror of
https://github.com/microsoft/Web-Dev-For-Beginners.git
synced 2025-09-24 21:41:37 +02:00
basic structure
This commit is contained in:
1
09-chat-project/backend/api.py
Normal file
1
09-chat-project/backend/api.py
Normal file
@@ -0,0 +1 @@
|
||||
# api
|
28
09-chat-project/backend/llm.py
Normal file
28
09-chat-project/backend/llm.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
from openai import OpenAI
|
||||
|
||||
# To authenticate with the model you will need to generate a personal access token (PAT) in your GitHub settings.
|
||||
# Create your PAT token by following instructions here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
|
||||
client = OpenAI(
|
||||
base_url="https://models.github.ai/inference",
|
||||
api_key=os.environ["GITHUB_TOKEN"],
|
||||
)
|
||||
|
||||
response = client.chat.completions.create(
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "What is the capital of France?",
|
||||
}
|
||||
],
|
||||
model="openai/gpt-4o-mini",
|
||||
temperature=1,
|
||||
max_tokens=4096,
|
||||
top_p=1
|
||||
)
|
||||
|
||||
print(response.choices[0].message.content)
|
1
09-chat-project/frontend/app.js
Normal file
1
09-chat-project/frontend/app.js
Normal file
@@ -0,0 +1 @@
|
||||
// js code
|
6
09-chat-project/frontend/index.html
Normal file
6
09-chat-project/frontend/index.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Chat app</title>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
3
09-chat-project/frontend/styles.css
Normal file
3
09-chat-project/frontend/styles.css
Normal file
@@ -0,0 +1,3 @@
|
||||
/* body {
|
||||
|
||||
} */
|
Reference in New Issue
Block a user