Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ausboss
ausboss / ollama_math_expression.py
Last active July 26, 2024 04:01
ollama_math_expression.py
import json
import ollama
import asyncio
import sympy as sp
def evaluate_math_expression(expression: str) -> str:
try:
result = sp.sympify(expression).evalf()
return json.dumps({"result": str(result)})
except Exception as e: