File size: 3,436 Bytes
22e913c f79f08b 22e913c cc6a9e3 22e913c f79f08b 22e913c cc6a9e3 22e913c cc6a9e3 22e913c |
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
import streamlit as st
from langchain import OpenAI, PromptTemplate, LLMChain
from langchain.text_splitter import CharacterTextSplitter
from langchain.chains.mapreduce import MapReduceChain
from langchain.prompts import PromptTemplate
from langchain.chat_models import AzureChatOpenAI
from langchain.chains.summarize import load_summarize_chain
from langchain.chains import AnalyzeDocumentChain
from PyPDF2 import PdfReader
from langchain.document_loaders import TextLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.document_loaders import PyPDFLoader
import os
import openai
import os
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"
openai.api_type = "azure"
openai.api_base = "https://embeddinguseopenai.openai.azure.com/"
openai.api_version = "2023-03-15-preview"
openai.api_key = os.environ["OPENAI_API_KEY"]
st.title("Wipro demo with azure cognitive 2 ")
atemprature = st.slider('Fact vs Creative?', 0, 10, 1)
atemprature = atemprature / 10.0
yourquestion = st.text_input('Your Question', 'First identify the indicators required as per EFRAG Environmental document. List these indicators. For each of these indicators, find out how Wipro is performing.')
st.write('Your input is ', yourquestion)
if st.button("Ask Questions "):
template = """
You are an AI assistant.
{concept}
"""
response = openai.ChatCompletion.create(
engine="gpt-35-turbo",
messages = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":yourquestion}],
temperature=atemprature,
max_tokens=800,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=None)
# Run the chain only specifying the input variable.
st.write(response)
if st.button("Ask Questions Simplify "):
template = """
You are an AI assistant.
{concept}
"""
response = openai.ChatCompletion.create(
engine="gpt-35-turbo",
messages = [{"role":"system","content":"You are an AI assistant that helps people find information. Please explain the information like i am a five."},{"role":"user","content":yourquestion}],
temperature=0,
max_tokens=800,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=None)
# Run the chain only specifying the input variable.
st.write(response)
if st.button("Ask trying here "):
template = """
You are an expert on topics of Sustainability, Climate action and UN Sustainable Development Goals.
Explain the concept of {concept} like i am a five
"""
prompt = PromptTemplate(
input_variables=["concept"],
template=template,
)
from langchain.chains import LLMChain
chain = LLMChain(llm=llm, prompt=prompt)
# Run the chain only specifying the input variable.
st.write(chain.run(yourquestion))
if st.button("Ask Hindi "):
template = """
You are an expert on topics of Sustainability, Climate action and UN Sustainable Development Goals.
Explain the concept of {concept} in Hindi
"""
prompt = PromptTemplate(
input_variables=["concept"],
template=template,
)
from langchain.chains import LLMChain
chain = LLMChain(llm=llm, prompt=prompt)
# Run the chain only specifying the input variable.
st.write(chain.run(yourquestion))
|