Spaces:
Sleeping
Sleeping
commit_8
Browse files
app.py
CHANGED
@@ -11,13 +11,13 @@ from langchain.document_loaders import PyPDFLoader, TextLoader, JSONLoader, CSVL
|
|
11 |
import tempfile # μμ νμΌμ μμ±νκΈ° μν λΌμ΄λΈλ¬λ¦¬μ
λλ€.
|
12 |
import os
|
13 |
from huggingface_hub import hf_hub_download # Hugging Face Hubμμ λͺ¨λΈμ λ€μ΄λ‘λνκΈ° μν ν¨μμ
λλ€.
|
14 |
-
from langchain.agents import (
|
15 |
-
|
16 |
-
|
17 |
-
)
|
18 |
-
from langchain.agents.agent_toolkits import JsonToolkit
|
19 |
-
from langchain.llms.openai import OpenAI
|
20 |
-
from langchain.tools.json.tool import JsonSpec
|
21 |
|
22 |
# PDF λ¬Έμλ‘λΆν° ν
μ€νΈλ₯Ό μΆμΆνλ ν¨μμ
λλ€.
|
23 |
def get_pdf_text(pdf_docs):
|
@@ -56,15 +56,15 @@ def get_json_file(docs):
|
|
56 |
f.write(docs.getvalue())
|
57 |
json_loader = JSONLoader(temp_filepath, jq_schema='.', text_content=False)
|
58 |
json_data = json_loader.load()
|
59 |
-
json_spec = JsonSpec(dict_=json_data, max_value_length=4000)
|
60 |
-
json_toolkit = JsonToolkit(spec=json_spec)
|
61 |
-
json_agent_executor = create_json_agent(
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
)
|
66 |
-
json_doc = json_agent_executor.execute(text=temp_filepath)
|
67 |
-
return
|
68 |
|
69 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
70 |
def get_text_chunks(documents):
|
|
|
11 |
import tempfile # μμ νμΌμ μμ±νκΈ° μν λΌμ΄λΈλ¬λ¦¬μ
λλ€.
|
12 |
import os
|
13 |
from huggingface_hub import hf_hub_download # Hugging Face Hubμμ λͺ¨λΈμ λ€μ΄λ‘λνκΈ° μν ν¨μμ
λλ€.
|
14 |
+
# from langchain.agents import (
|
15 |
+
# create_json_agent,
|
16 |
+
# AgentExecutor
|
17 |
+
# )
|
18 |
+
# from langchain.agents.agent_toolkits import JsonToolkit
|
19 |
+
# from langchain.llms.openai import OpenAI
|
20 |
+
# from langchain.tools.json.tool import JsonSpec
|
21 |
|
22 |
# PDF λ¬Έμλ‘λΆν° ν
μ€νΈλ₯Ό μΆμΆνλ ν¨μμ
λλ€.
|
23 |
def get_pdf_text(pdf_docs):
|
|
|
56 |
f.write(docs.getvalue())
|
57 |
json_loader = JSONLoader(temp_filepath, jq_schema='.', text_content=False)
|
58 |
json_data = json_loader.load()
|
59 |
+
# json_spec = JsonSpec(dict_=json_data, max_value_length=4000)
|
60 |
+
# json_toolkit = JsonToolkit(spec=json_spec)
|
61 |
+
# json_agent_executor = create_json_agent(
|
62 |
+
# llm=OpenAI(temperature=0),
|
63 |
+
# toolkit=json_toolkit,
|
64 |
+
# verbose=True
|
65 |
+
# )
|
66 |
+
# json_doc = json_agent_executor.execute(text=temp_filepath)
|
67 |
+
return json_data
|
68 |
|
69 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
70 |
def get_text_chunks(documents):
|