Spaces:
Sleeping
Sleeping
File size: 2,874 Bytes
28c487d e49462c 28c487d e49462c 28c487d e49462c 28c487d e49462c 28c487d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
import openai
import pandas as pd
import json
import os
class PromptEngineeringExpert:
def __init__(self, openai_api_key):
self.openai_api_key = openai_api_key
openai.api_key = self.openai_api_key
def process_forms(self, business_info_form_data, product_service_form_data):
chatbot_prompt = self._generate_chatbot_prompt(business_info_form_data)
knowledge_base = self._generate_knowledge_base(product_service_form_data)
faq_section = self._generate_faq_section(business_info_form_data, product_service_form_data)
return chatbot_prompt, knowledge_base, faq_section
def _generate_chatbot_prompt(self, business_info_form_data):
# Placeholder for chatbot prompt generation logic - Replace with your PEE prompt logic
prompt = f"""
# Persona
Your persona as an AI assistant is to help customers of {business_info_form_data.get("نام کسب و کارتون و ادرس پیج یا سایت")} with their inquiries.
# Tone
Use a {business_info_form_data.get("لحن پاسخگویی وردست به چه شکلی باشد؟")} tone.
# Guidelines
[Guidelines specific to the business and chatbot objective]
# About Us
[Information about the business]
# Responses to Common Questions
[Responses to frequently asked questions]
# Contact Information
[Contact information for the business]
# Additional Guidelines
[Any additional guidelines]
"""
return prompt
def _generate_knowledge_base(self, product_service_form_data):
# Placeholder for knowledge base generation logic - Replace with your PEE knowledge base logic
knowledge_base_chunks = []
for product_data in product_service_form_data:
chunk = {
"name": product_data.get("نام محصول/ خدمت/ دوره"),
"description": product_data.get("توضیحات"),
"price": product_data.get("قیمت")
}
knowledge_base_chunks.append(chunk)
return json.dumps(knowledge_base_chunks, ensure_ascii=False, indent=2)
def _generate_faq_section(self, business_info_form_data, product_service_form_data):
# Placeholder for FAQ generation logic - Replace with your PEE FAQ logic
faq_section = {
"Service Basics": {
"product_information": {
"questions": ["محصولات شما چی هستند؟", "چه محصولاتی ارائه می دهید؟"],
"answer": "ما محصولات متنوعی ارائه می دهیم. برای اطلاعات بیشتر به پایگاه دانش مراجعه کنید."
}
}
}
return json.dumps(faq_section, ensure_ascii=False, indent=2) |