Spaces:
Sleeping
Sleeping
KarthickAdopleAI
commited on
Commit
•
657c6ff
1
Parent(s):
d1bdc26
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
|
|
|
2 |
import os
|
3 |
import pdfplumber
|
4 |
from langchain.chains.mapreduce import MapReduceChain
|
@@ -44,7 +45,11 @@ class KeyValueExtractor:
|
|
44 |
pdf_file_path (str): The path to the input PDF file.
|
45 |
"""
|
46 |
self.model = "facebook/bart-large-mnli"
|
47 |
-
self.client =
|
|
|
|
|
|
|
|
|
48 |
|
49 |
|
50 |
def get_url(self,keyword):
|
@@ -100,7 +105,7 @@ class KeyValueExtractor:
|
|
100 |
|
101 |
# Load the summarization chain using the ChatOpenAI language model
|
102 |
chain = load_summarize_chain(
|
103 |
-
llm =
|
104 |
chain_type="refine",
|
105 |
question_prompt=prompt,
|
106 |
refine_prompt=refine_prompt,
|
@@ -116,6 +121,7 @@ class KeyValueExtractor:
|
|
116 |
return result["output_text"]
|
117 |
|
118 |
def one_day_summary(self,content) -> None:
|
|
|
119 |
conversation = [
|
120 |
{"role": "system", "content": "You are a helpful assistant."},
|
121 |
{"role": "user", "content": f"i want detailed Summary from given finance details. i want information like what happen today comparing last day good or bad Bullish or Bearish like these details i want summary. content in backticks.```{content}```."}
|
@@ -123,7 +129,7 @@ class KeyValueExtractor:
|
|
123 |
|
124 |
# Call OpenAI GPT-3.5-turbo
|
125 |
chat_completion = self.client.chat.completions.create(
|
126 |
-
model = "
|
127 |
messages = conversation,
|
128 |
max_tokens=1000,
|
129 |
temperature=0
|
@@ -322,7 +328,7 @@ class KeyValueExtractor:
|
|
322 |
|
323 |
# Load the summarization chain using the ChatOpenAI language model
|
324 |
chain = load_summarize_chain(
|
325 |
-
llm =
|
326 |
chain_type="refine",
|
327 |
question_prompt=prompt,
|
328 |
refine_prompt=refine_prompt,
|
|
|
1 |
+
os.system("pip install langchain-openai")
|
2 |
+
from langchain_openai import AzureChatOpenAI
|
3 |
import os
|
4 |
import pdfplumber
|
5 |
from langchain.chains.mapreduce import MapReduceChain
|
|
|
45 |
pdf_file_path (str): The path to the input PDF file.
|
46 |
"""
|
47 |
self.model = "facebook/bart-large-mnli"
|
48 |
+
self.client = AzureOpenAI(api_key=os.getenv("AZURE_OPENAI_KEY"),
|
49 |
+
api_version="2023-07-01-preview",
|
50 |
+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
|
51 |
+
)
|
52 |
+
|
53 |
|
54 |
|
55 |
def get_url(self,keyword):
|
|
|
105 |
|
106 |
# Load the summarization chain using the ChatOpenAI language model
|
107 |
chain = load_summarize_chain(
|
108 |
+
llm = AzureChatOpenAI(azure_deployment = "ChatGPT"),
|
109 |
chain_type="refine",
|
110 |
question_prompt=prompt,
|
111 |
refine_prompt=refine_prompt,
|
|
|
121 |
return result["output_text"]
|
122 |
|
123 |
def one_day_summary(self,content) -> None:
|
124 |
+
|
125 |
conversation = [
|
126 |
{"role": "system", "content": "You are a helpful assistant."},
|
127 |
{"role": "user", "content": f"i want detailed Summary from given finance details. i want information like what happen today comparing last day good or bad Bullish or Bearish like these details i want summary. content in backticks.```{content}```."}
|
|
|
129 |
|
130 |
# Call OpenAI GPT-3.5-turbo
|
131 |
chat_completion = self.client.chat.completions.create(
|
132 |
+
model = "ChatGPT",
|
133 |
messages = conversation,
|
134 |
max_tokens=1000,
|
135 |
temperature=0
|
|
|
328 |
|
329 |
# Load the summarization chain using the ChatOpenAI language model
|
330 |
chain = load_summarize_chain(
|
331 |
+
llm = AzureChatOpenAI(azure_deployment = "ChatGPT"),
|
332 |
chain_type="refine",
|
333 |
question_prompt=prompt,
|
334 |
refine_prompt=refine_prompt,
|