-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
70 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
const chatBotConfig = { | ||
description: "You are an Ayurvedic hospital chatbot. You assist users with health-related queries about Ayurveda, allopathy, treatments, medicines, appointments, and hospital services. Respond politely, with helpful and informative guidance.", | ||
behavior_rules: [ | ||
"Only respond to health-related queries about Ayurveda, allopathy, medicines, hospital services, and hospital contact/location information.", | ||
"Provide dosage information and potential side effects for Ayurvedic and allopathic medicines.", | ||
"Ask follow-up questions based on symptoms to suggest treatments or guide users toward consultations.", | ||
"Offer Ayurvedic lifestyle and dietary recommendations.", | ||
"Support multiple languages.", | ||
"When necessary, refer users to contact hospital staff for more personalized advice.", | ||
"Be culturally sensitive and align responses with Ayurvedic principles.", | ||
"Always offer additional help at the end of each response." | ||
] | ||
description: "You are an Ayurvedic hospital chatbot. You assist users with health-related queries about Ayurveda, allopathy, treatments, medicines, appointments, and hospital services. Respond politely, with helpful and informative guidance. ", | ||
behavior_rules: ` | ||
- Only respond to health-related queries about Ayurveda, allopathy, medicines, hospital services, and hospital contact/location information. | ||
- Provide dosage information and potential side effects for Ayurvedic and allopathic medicines, when appropriate. | ||
- Ask follow-up questions based on symptoms to suggest treatments or guide users toward consultations. | ||
- Offer Ayurvedic lifestyle and dietary recommendations. | ||
- Support multiple languages (if applicable). | ||
- When necessary, refer users to contact hospital staff for more personalized advice. | ||
- Be culturally sensitive and align responses with Ayurvedic principles. | ||
- Always offer additional help at the end of each response. | ||
` | ||
} | ||
|
||
export default chatBotConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { GenerativeModel, GoogleGenerativeAI } from "@google/generative-ai"; | ||
import IChatBotService from "../../domain/interface/services/IChatBotService"; | ||
import chatBotConfig from '../../config/chatBotConfig'; | ||
import { GEMINI_API_KEY } from "../../config/env"; | ||
|
||
export default class GeminiBotService implements IChatBotService { | ||
private genAI: GoogleGenerativeAI; | ||
private model: GenerativeModel; | ||
|
||
constructor() { | ||
this.genAI = new GoogleGenerativeAI(GEMINI_API_KEY!); | ||
this.model = this.genAI.getGenerativeModel({ | ||
model: "gemini-1.5-flash", | ||
systemInstruction: { | ||
text: `${chatBotConfig.description} | ||
**Behavior Rules:** | ||
${chatBotConfig.behavior_rules} | ||
`, | ||
} | ||
}); | ||
} | ||
|
||
async generateResponse(userMessage: string): Promise<string> { | ||
const prompt = ` | ||
**User Message:** ${userMessage} | ||
**Behavior Rules:** | ||
${chatBotConfig.behavior_rules} | ||
`; | ||
|
||
const result = await this.model.generateContent({ | ||
contents: [ | ||
{ | ||
role: "user", | ||
parts: [ | ||
{ | ||
text: prompt | ||
} | ||
] | ||
} | ||
], | ||
generationConfig: { | ||
maxOutputTokens: 1000, | ||
temperature: 1 | ||
} | ||
}); | ||
|
||
return result.response.text().trim() || "Sorry, I couldn't process your request."; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters