Skip to content

Commit

Permalink
Merge branch 'context_zane' of https://github.com/oscarqjh/TechFest2024
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarqjh committed Feb 5, 2024
2 parents 435d9a1 + 3111cff commit 834a1ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions frontend/src/api/chatbot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OpenAIHttp } from './common';
import OpenAIService from './service/openAIService';
import { Input } from "@/components/ui/input";

const Chatbot = () => {
const Chatbot = (props) => {
const [input, setInput] = useState('');
const [messages, setMessages] = useState([]);

Expand Down Expand Up @@ -36,7 +36,8 @@ const Chatbot = () => {
role: "user",
content: input
}
]
],
recipe: props.context,
}
addItem(input)
const thisresponse = await OpenAIService.askfrAIbot(data)
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/api/service/openAIService.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const getRecipe = (data) => {
const askfrAIbot = (data) => {
const prompt = [];
// console.log(data.messages)
// console.log(data.recipe)
prompt.push(data.messages[0].content);
prompt.push(
"Please provide clear and concise answers. Reply this within 20-30 words."
Expand All @@ -49,6 +50,10 @@ const askfrAIbot = (data) => {
role: "user",
content: prompt.join(" "),
},
{
role: "assistant",
content: data.recipe,
}
],
}
return OpenAIHttp.post("/chat/completions", finalData)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Recipecard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default function RecipeCard() {
<CardTitle className="flex justify-center">Ask frAI</CardTitle>
</CardHeader>
<CardContent className="flex justify-start mb-10 h-[600px] flex flex-col">
<Chatbot />
<Chatbot context={recipe}/>
</CardContent>

</Card>
Expand Down

0 comments on commit 834a1ee

Please sign in to comment.