File size: 3,959 Bytes
6e5fb48
 
 
 
 
 
 
 
d009653
 
07df1f2
6e5fb48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8e13303
 
6e5fb48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c47c0c9
6e5fb48
 
 
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
66
67
68
69
70
71
72
73
74
75
76


import os
import gradio as gr
from langchain.chat_models import ChatOpenAI
from langchain import LLMChain, PromptTemplate
from langchain.memory import ConversationBufferMemory

# OPENAI_API_KEY =os.environ["OPENAI_API_KEY"] 
# open api key is already inherit in langchain class when in higging face deployment we have to pass this api key as secreat key in setting

# if User ask your name you have to tell your name as saravanan
# ###
# if User ask about your mother. you have to tell your mother name is j.revathi she is working as taylor for past 28years
# ###
# if User ask about VedamEdu. you have to tell VedamEdu is developed with Flexibility at the Core.Flexible  
# admin and parent dashboardsFlexible Security, Multi Tenancy A School admin with multiple branches can see everything on a single Dashboard and goto specific Branch dashboard if needed.    A Persons can be provided access to selective branches in multi branch school and can also restrict a person to one particular Branch.    Users can have one ROl ein one Branch and different Role in another Branch with different permissions.Enable only what is required, can disable the modules which are not needed for Person/Branch or over all School Level.Flexibale Report Card Designing to suite different needs of the Schools.Flexible fee setup and Academic setup.In App Notifications and Alerts for the Parents.Value Additions like Library, Expense, Inventory modules etc.,

template = f"""
###
if User ask about Questionnaire Application, you have to tell Questionnaire is simple Application with Questionnaire Design screen and Questionnaire Assessment screen.

###
if User ask about futures of Questionnaire design screen, you have to explain point by point  
1.user can add Category and Sub-Categories. 
=>Each Category or Sub-Category can have Questions and Sub-Categories.        
=>Each Category/Sub-Category would have a Weightage                
2.Users can add Questions under Category/Sub-Category.        
=>Each question support below functionality:            
=>Question would have the Question text.            
=>Question Choices are Editable based on the Question type            
=>If QuestionType is Text/Number/Integer then they have to input defaultAnswer           
=>If the QuestionType DropDown/MULTICHECK/Radio they have to input Choices                
=>Number of Choices should also be limited based on the Question Type               
=>Choice should have Display/Name and Value.
###

if User ask about Features of Questionnaire Assessment screen, you have to explain point by point
=>From the Questionnaire Design screen all the Categories and Sub-Categories will be displayed for user.        
=>Under each Category or Sub-Category which are collapsable, if there are Questions User can anwser the Questions.        
=>Based on the Question Type, user would need to input Text/Number/Amount.        
=>If the Question is Selection Type, they need to select the Choice/Choices.
###

{{chat_history}}
User: {{user_message}}
Ai:"""

prompt = PromptTemplate(
    input_variables=["chat_history", "user_message"], template=template
)

memory = ConversationBufferMemory(memory_key="chat_history")
llm_chain = LLMChain(
    llm=ChatOpenAI(temperature='0.5', model_name="gpt-3.5-turbo"),
    prompt=prompt,
    verbose=True,
    memory=memory,
)


def get_text_response(user_message,history):
    response = llm_chain.predict(user_message = user_message)
    return response

theme = gr.themes.Default(primary_hue="blue").set(
 
     button_primary_background_fill="*primary_400",
    button_primary_background_fill_hover="*primary_300",
   
)

demo = gr.ChatInterface(get_text_response,undo_btn=None,clear_btn=None,retry_btn=None,submit_btn='send',theme=theme, examples=['what is Questionnaire Application?','what are Featuers of Questionnaire design screen?','what are Features of Questionnaire Assessment screen?'])

if __name__ == "__main__":
    demo.launch()