{ "cells": [ { "cell_type": "code", "execution_count": 8, "id": "01032c82-239c-48bf-82dc-cf91a2dd4698", "metadata": {}, "outputs": [], "source": [ "import ollama\n", "import gradio as gr" ] }, { "cell_type": "code", "execution_count": 9, "id": "d17e8da0-72e6-4d11-9f99-64d83d6bb77b", "metadata": {}, "outputs": [], "source": [ "system_prompt_llama = \"You are an assistant that solves a quadratic equation provided. Just write the steps and the final answer and nothing else\"\n", "user_prompt_llama = \"This is the quadratic equation you have to solve: \"\n", "user_prompt_deepseek = \"This is the quadratic equation you have to solve: \"\n", "system_prompt_deepseek = \"You are an assistant that solves a quadratic equation provided. Just write the steps and the final answer and nothing else\"" ] }, { "cell_type": "code", "execution_count": 10, "id": "e5ed88b2-090f-4364-b334-c6ff66676d82", "metadata": {}, "outputs": [], "source": [ "default_equation = \"x² - 5x + 6\"" ] }, { "cell_type": "code", "execution_count": 11, "id": "3aa1ed93-15ea-4d97-a00d-dbda21450ad7", "metadata": {}, "outputs": [], "source": [ "people_dict = {}" ] }, { "cell_type": "code", "execution_count": 12, "id": "9361e9e6-99eb-45b0-ba31-3cf1b0865936", "metadata": {}, "outputs": [], "source": [ "def llama(equation):\n", " message_ = [{'role':'system', 'content':system_prompt_llama}, {'role':'user', 'content':user_prompt_llama+equation}]\n", " res = ollama.chat(model=\"llama3.2\", messages=message_)\n", " return res['message']['content']\n", " \n", "def deepseek(equation):\n", " message_ = [{'role':'system', 'content':system_prompt_deepseek}, {'role':'user', 'content':user_prompt_deepseek+equation}]\n", " res = ollama.chat(model=\"deepseek-r1:1.5b\", messages=message_)\n", " return res['message']['content']\n", " " ] }, { "cell_type": "code", "execution_count": 13, "id": "e6ddaf09-996f-4cfa-af98-49bf1d7d5ab3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "* Running on local URL: http://127.0.0.1:7872\n", "* Running on public URL: https://7a723fc085cc9ad458.gradio.live\n", "\n", "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "