Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,6 @@ from Data import markdown_to_csv
|
|
6 |
from langchain_core.prompts import ChatPromptTemplate
|
7 |
from langchain_openai import ChatOpenAI
|
8 |
|
9 |
-
# Load OpenRouter API Key
|
10 |
-
openrouter_api_key = "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"
|
11 |
-
|
12 |
-
model = ChatOpenAI(
|
13 |
-
openai_api_key=openrouter_api_key,
|
14 |
-
model="meta-llama/llama-4-maverick:free",
|
15 |
-
base_url="https://openrouter.ai/api/v1"
|
16 |
-
)
|
17 |
|
18 |
st.title("AI Web Scraper")
|
19 |
|
@@ -72,25 +64,3 @@ if "all_dom_content" in st.session_state:
|
|
72 |
else:
|
73 |
st.write("No tables to merge.")
|
74 |
|
75 |
-
def merge_tables_with_llm(tables, parse_description):
|
76 |
-
"""Merges a list of Pandas DataFrames into a single Markdown table using LLM."""
|
77 |
-
from langchain_core.prompts import ChatPromptTemplate
|
78 |
-
from langchain_openai import ChatOpenAI
|
79 |
-
# Convert DataFrames to Markdown strings
|
80 |
-
table_strings = [table.to_markdown(index=False) for table in tables]
|
81 |
-
|
82 |
-
# Create a prompt for the LLM
|
83 |
-
merge_prompt = (
|
84 |
-
"You are tasked with merging the following Markdown tables into a single, comprehensive Markdown table.\n"
|
85 |
-
"The tables contain information related to: {parse_description}.\n"
|
86 |
-
"Combine the tables, ensuring that the merged table is well-formatted and contains all relevant information.\n"
|
87 |
-
"If there are duplicate columns, rename them to be unique. If there are missing values, fill them with 'N/A'.\n"
|
88 |
-
"Ensure the final output is a single valid Markdown table.\n\n"
|
89 |
-
"Here are the tables:\n\n" + "\n\n".join(table_strings) +
|
90 |
-
"\n\nReturn the merged table in Markdown format:"
|
91 |
-
)
|
92 |
-
|
93 |
-
# Invoke the LLM
|
94 |
-
response = model.invoke({"dom_content": "", "parse_description": merge_prompt})
|
95 |
-
return response.content
|
96 |
-
|
|
|
6 |
from langchain_core.prompts import ChatPromptTemplate
|
7 |
from langchain_openai import ChatOpenAI
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
st.title("AI Web Scraper")
|
11 |
|
|
|
64 |
else:
|
65 |
st.write("No tables to merge.")
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|