themissingCRAM
commited on
Commit
·
1b0cc5f
1
Parent(s):
97413fe
switch to llama llm 4 && git push
Browse files
@tool
def sql_engine_tool(
query: str,
) -> str:
"""
Allows you to perform SQL queries on the table. Returns a string representation of the result.
The table is named receipts. Its description is as follows:
Columns:
- receipt_id: INTEGER
- customer_name: VARCHAR(16)
- price: FLOAT
- tip: FLOAT
Args:
query: The query to perform. This should be correct SQL.
"""
output = ""
with engine.connect() as con:
rows = con.execute(text(query))
for row in rows:
output += "\n" + str(row)
return output
app.py
CHANGED
|
@@ -47,6 +47,7 @@ def sql_engine_tool(
|
|
| 47 |
|
| 48 |
"""
|
| 49 |
output = ""
|
|
|
|
| 50 |
with engine.connect() as con:
|
| 51 |
rows = con.execute(text(query))
|
| 52 |
for row in rows:
|
|
@@ -94,6 +95,7 @@ def init_db(engine):
|
|
| 94 |
insert_rows_into_table(rows, receipts)
|
| 95 |
with engine.begin() as conn:
|
| 96 |
print("SELECT test", conn.execute(text("SELECT * FROM receipts")).fetchall())
|
|
|
|
| 97 |
return engine
|
| 98 |
|
| 99 |
|
|
@@ -101,7 +103,7 @@ if __name__ == "__main__":
|
|
| 101 |
engine = create_engine("sqlite:///:memory:")
|
| 102 |
engine = init_db(engine)
|
| 103 |
model = HfApiModel(
|
| 104 |
-
model_id="",
|
| 105 |
token=os.getenv("my_first_agents_hf_tokens"),
|
| 106 |
)
|
| 107 |
|
|
|
|
| 47 |
|
| 48 |
"""
|
| 49 |
output = ""
|
| 50 |
+
print(engine)
|
| 51 |
with engine.connect() as con:
|
| 52 |
rows = con.execute(text(query))
|
| 53 |
for row in rows:
|
|
|
|
| 95 |
insert_rows_into_table(rows, receipts)
|
| 96 |
with engine.begin() as conn:
|
| 97 |
print("SELECT test", conn.execute(text("SELECT * FROM receipts")).fetchall())
|
| 98 |
+
print(engine)
|
| 99 |
return engine
|
| 100 |
|
| 101 |
|
|
|
|
| 103 |
engine = create_engine("sqlite:///:memory:")
|
| 104 |
engine = init_db(engine)
|
| 105 |
model = HfApiModel(
|
| 106 |
+
model_id="meta-llama/Meta-Llama-3.1-8B-Instruct",
|
| 107 |
token=os.getenv("my_first_agents_hf_tokens"),
|
| 108 |
)
|
| 109 |
|