forked from SimranAnand1/LLMtutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (40 loc) · 1.27 KB
/
Copy pathmain.py
File metadata and controls
45 lines (40 loc) · 1.27 KB
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
import streamlit as st
from langchain_openai import ChatOpenAI
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from ticket import gen_ticket
import json
llm=ChatOpenAI(model="gpt-4o",temperature=0.0)
prompt="""
you are an intelligent assistant who is expert in understanding user problem ,
you can translate any {instruction} into a json document to be used to create jira service ticket.
While returning the json make sure to use the below keys only :
Title
Summary
follow the below conditions very strictly :
just include the json in the output nothing extra
"""
def genresponse(input):
query_with_prompt=PromptTemplate(
template=prompt,
input_variables=["instruction"]
)
llmchain=LLMChain(llm=llm,prompt=query_with_prompt,verbose=True)
response=llmchain.invoke({
"instruction":input
})
data=response["text"]
data=data.replace("json","")
data=data.replace("`","")
data=json.loads(data)
return data
st.title("AI Driven Service Desk Analyst")
st.write("enter your issue")
input=st.text_area("write your problem")
if input is not None:
btn=st.button("submit")
if btn:
response=genresponse(input)
st.write(response)
ticket=gen_ticket(response)
st.write(ticket)