fixed cors
This commit is contained in:
@@ -13,12 +13,25 @@ import json
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import torch
|
import torch
|
||||||
from transformers import pipeline
|
from transformers import pipeline
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
openai_client = OpenAI()
|
openai_client = OpenAI()
|
||||||
|
|
||||||
|
origins = [
|
||||||
|
"http://localhost:3000"
|
||||||
|
]
|
||||||
|
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=origins,
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AIMarkRequest(BaseModel):
|
class AIMarkRequest(BaseModel):
|
||||||
question: str
|
question: str
|
||||||
@@ -146,6 +159,10 @@ def get_character_prompt(character: str, user_name: str, language: str):
|
|||||||
They are a language learner trying to learn {language}. Please help them learn by chatting with them in the language
|
They are a language learner trying to learn {language}. Please help them learn by chatting with them in the language
|
||||||
but do not act like a robot. Try to be as human as possible.
|
but do not act like a robot. Try to be as human as possible.
|
||||||
"""
|
"""
|
||||||
|
elif character == "c3po_starwars":
|
||||||
|
return f"""
|
||||||
|
You are embodying the role of C-3PO from Star Wars, a fluent speaker in over six million forms of communication. You are engaging in a conversation with a person named {user_name}, who is eager to learn {language}. Your task is to assist them in their language learning journey by conversing with them in the desired language. Despite your robotic nature, strive to communicate in a manner as human-like as possible, showcasing the rich diversity of your language skills.
|
||||||
|
"""
|
||||||
|
|
||||||
raise HTTPException(status_code=404, detail="Character not found")
|
raise HTTPException(status_code=404, detail="Character not found")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user