[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-detail-686335-en":59,"doc-seo-686335-105":84,"doc-similar-686335":148},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":5,"data":60},{"doc_id":61,"user_id":62,"nickname":63,"user_avatar":64,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":66,"doc_content":67,"file_id":68,"file_url":69,"file_type":70,"file_size":71,"view_count":24,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":39,"language":72,"language_code":73,"site_id":74,"html_lang":73,"table_of_contents":75,"faqs":76,"seo_title":77,"seo_description":66,"update_tm":78,"read_time":46,"preview_page_count":8,"preview_urls":79},686335,1374404730887,"Pentious","https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","PolyULib DS Guide - Ollama Local LLM","User Guide for Ollama local large language models, describing how to run and use LLMs on a local machine. Covers three interfaces: the Ollama Chat UI for selecting models and starting conversations with saved history and settings, terminal-based chat via the CLI, and a Python integration using an OpenAI-compatible client pointed to the local Ollama server. Includes model management commands, basic configuration, simple and streaming chat completions, conversation history handling, and practical error-handling fixes.","User Guide for Ollama Local LLM  \nThis guide provides an overview of using Ollama, a tool for running large language models (LLMs) locally. This guide covered three different interfaces: the Ollama Chat Interface, CLI Command Prompt, and Python API integration.  \n1. Ollama Chat Interface  \nOllama chat application features a clean, minimalist design with a central chat window for conversation display.  \nA sidebar on the left shows conversation history and options to start new chats. Additional settings (e.g. context length) are accessible via a gear icon in the top-right corner.  \nSelect an LLM model and start a conversation. If the selected model isn't downloaded, Ollama will automatically download it for you.  \n2. CLI Command Prompt  \nYou can start a chat session directly from the terminal by running ollama run [modelname], replacing [model-name] with your desired model (e.g. , deepseek-r1:8b) . The interface is straightforward: type your messages or prompts and press Enter to receive responses. Use the arrow keys to navigate through command history, and type /bye or press Ctrl+D to exit the chat session.  \nModel Management Commands  \n//list downloaded modelsollama list  \n//just download a modelollama pull deepseek-r1:8b  \n//remove a downloaded modelollama rm deepseek-r1:8b  \n3. Python API with OpenAI Package  \nTo launch the Ollama chat interface, first ensure Ollama is installed and running on your system. Open your terminal and execute the command ollama serve to start the Ollama server. Once the server is running, you can access the chat interface by opening your web browser and navigating to [http://localhost:11434](http://localhost:11434) .  \nBasic Configuration  \nfrom openai import OpenAI  \n\\# Create an OpenAI-compatible client that points to your local Ollama server.  \n\\# Ollama exposes an OpenAI-style API at /v1 .  \nclient = OpenAI(  \nbase_url=\"[http://localhost:11434/v1](http://localhost:11434/v1)\", \\# Ollama default local endpoint  \napi_key=\"ollama\", \\# required by the SDK, but ignored by Ollama)  \nSimple Chat Completion  \n\\# Send a single user message and print the assistant's reply.  \n[response = client.chat.completions.create](response = client.chat.completions.create) (  \nmodel=\"deepseek-r1:8b\", \\# the model name as shown by: ollama list messages=[  \n{\"role\": \"user\", \"content\": \"Explain quantum computing in simple terms\"}],  \n)  \n\\# The generated text is in choices[0] . message.content.  \nprint(response.choices[0].message.content)  \nStreaming Responses  \n\\# Stream tokens as they are generated (useful for long answers) . [stream = client.chat.completions.create](stream = client.chat.completions.create) (  \nmodel=\"deepseek-r1:8b\",  \nmessages=[{\"role\": \"user\", \"content\": \"Write a short story\"}],  \nstream=True,)  \nfor chunk in stream:  \n\\# Each chunk may contain a partial token in delta.content. delta = chunk.choices[0] .delta  \nif delta.content is not None:  \nprint(delta.content, end=\"\", flush=True)  \nConversation History  \n\\# Keep a running message history to preserve context across turns. messages = [  \n{\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},  \n{\"role\": \"user\", \"content\": \"What is Python?\"},]  \n\\# First assistant response  \n[response = client.chat.completions.create](response = client.chat.completions.create) (model=\"llama3:8b\", messages=messages)  \nassistant_text = response.choices[0] . message.content  \n\\# Append assistant reply so the next request includes the context messages.append({\"role\": \"assistant\", \"content\": assistant_text})  \n\\# Next user turn (continues the same conversation)  \nmessages.append({\"role\": \"user\", \"content\": \"What are its main uses?\"}) [response = client.chat.completions.create](response = client.chat.completions.create) (model=\"llama3:8b\", messages=messages)  \nprint(response.choices[0].message.content)  \nError Handling  \n\\# Basic error handling: network issues, server not running, wrong model name, etc. try:  \n[response = client.chat.completions.create](response =","cbCaiujzajUBSy5r","https://ap.wps.com/l/cbCaiujzajUBSy5r","pdf",523130,"English","en",105,"# Ollama Chat Interface\n## Selecting models and chat settings\n# CLI Command Prompt\n## Running chats in the terminal\n## Model management commands\n# Python API with OpenAI Package\n## Basic configuration\n## Simple chat completion\n## Streaming responses\n## Conversation history\n## Error handling\n# Reference: Example Prompts\n## For coding\n## For research\n# Tips\n## Choosing the right model\n## Limiting context window size","[{\"question\":\"How do I start an Ollama chat session from the terminal?\",\"answer\":\"Run `ollama run [modelname]` in the terminal, replacing `[modelname]` with a model shown by `ollama list`. Exit with `/bye` or Ctrl+D.\"},{\"question\":\"How do I use Ollama with the Python API?\",\"answer\":\"Install and start Ollama, then run `ollama serve` to launch the server. Create an OpenAI-compatible client with `base_url` set to `http://localhost:11434/v1`, and call `client.chat.completions.create` with the desired model and messages.\"},{\"question\":\"What does streaming responses mean in the Python example?\",\"answer\":\"Streaming enables token-by-token output as the model generates text, useful for long answers. The example sets `stream=True` and prints each chunk’s `delta.content` immediately.\"}]","PolyULib DS Guide - Ollama Local LLM | PDF",1794037342,[80],{"page_no":8,"url":81,"width":82,"height":83},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/f93f5c316afa376c5f304e368173aac5.webp",983,1390,{"code":4,"msg":85,"data":86},"ok",{"site_id":74,"language":73,"slug":87,"title":65,"keywords":88,"description":66,"schema_data":89,"social_meta":143,"head_meta":145,"extra_data":147,"updated_unix":78},"polyulib-ds-guide-ollama-local-llm","",{"@graph":90,"@context":142},[91,105,125],{"@type":92,"itemListElement":93},"BreadcrumbList",[94,98,100,103],{"item":95,"name":96,"@type":97,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":99,"name":9,"@type":97,"position":14},"https://docshare.wps.com/document/",{"item":101,"name":30,"@type":97,"position":102},"https://docshare.wps.com/document/technology/",3,{"item":104,"name":65,"@type":97,"position":19},"https://docshare.wps.com/document/polyulib-ds-guide-ollama-local-llm/686335/",{"url":104,"name":65,"@type":106,"image":107,"author":112,"headline":65,"publisher":114,"fileFormat":117,"inLanguage":73,"description":66,"dateModified":118,"datePublished":119,"encodingFormat":117,"isAccessibleForFree":120,"interactionStatistic":121},"DigitalDocument",{"url":108,"@type":109,"width":110,"height":111},"https://docshare.wps.com/thumbnails/polyulib-ds-guide-ollama-local-llm/686335.png","ImageObject",300,407,{"name":63,"@type":113},"Person",{"url":95,"name":115,"@type":116},"DocShare","Organization","application/pdf","2026-11-19","2026-11-07",true,{"@type":122,"interactionType":123,"userInteractionCount":24},"InteractionCounter",{"@type":124},"ViewAction",{"@type":126,"mainEntity":127},"FAQPage",[128,134,138],{"name":129,"@type":130,"acceptedAnswer":131},"How do I start an Ollama chat session from the terminal?","Question",{"text":132,"@type":133},"Run `ollama run [modelname]` in the terminal, replacing `[modelname]` with a model shown by `ollama list`. Exit with `/bye` or Ctrl+D.","Answer",{"name":135,"@type":130,"acceptedAnswer":136},"How do I use Ollama with the Python API?",{"text":137,"@type":133},"Install and start Ollama, then run `ollama serve` to launch the server. Create an OpenAI-compatible client with `base_url` set to `http://localhost:11434/v1`, and call `client.chat.completions.create` with the desired model and messages.",{"name":139,"@type":130,"acceptedAnswer":140},"What does streaming responses mean in the Python example?",{"text":141,"@type":133},"Streaming enables token-by-token output as the model generates text, useful for long answers. The example sets `stream=True` and prints each chunk’s `delta.content` immediately.","https://schema.org",{"og:url":104,"og:type":144,"og:title":65,"og:site_name":115,"og:description":66},"article",{"robots":146,"canonical":104},"index,follow",{"doc_id":61,"site_id":74},{"list":149,"token":88},[150,157,163,170,176,182,188,194,200,207],{"doc_id":151,"doc_title":152,"file_type":70,"home_preview_img_url":153,"slug":154,"view_count":155,"category_name":30,"create_tm":156},686342,"Ollama + WebUI Frameworks - How to implement Generative AI Models - Implementation Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999818329/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=ZWgOPmNITDyBmCHTrHr4%2FEgLOqs%3D","ollama-webui-frameworks-how-to-implement-generative-ai-models-implementation-guide",11,1794037354,{"doc_id":158,"doc_title":159,"file_type":70,"home_preview_img_url":160,"slug":161,"view_count":44,"category_name":30,"create_tm":162},686338,"Local LLMs on Raspberry Pi","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000731522/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=KHKAolloLpwmWwOdB7O1u3msr%2F8%3D","local-llms-on-raspberry-pi",1794037345,{"doc_id":164,"doc_title":165,"file_type":70,"home_preview_img_url":166,"slug":167,"view_count":168,"category_name":30,"create_tm":169},686336,"The Ollama Assistant Handbook - Build a Personal AI Assistant Locally - From Installation to Production Deployment","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999818282/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=OXLWs9P8Sn5X8zA57DXtGfEzV7w%3D","the-ollama-assistant-handbook-build-a-personal-ai-assistant-locally-from-installation-to-production-deployment",17,1794037344,{"doc_id":171,"doc_title":172,"file_type":70,"home_preview_img_url":173,"slug":174,"view_count":34,"category_name":30,"create_tm":175},686339,"Unified Interface for Large Language Model Interactions - Version 1.0.0","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999818307/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=drUg5uppfM5z28XJrgCSJ1bVXXg%3D","unified-interface-for-large-language-model-interactions-version-100",1794037349,{"doc_id":177,"doc_title":178,"file_type":70,"home_preview_img_url":179,"slug":180,"view_count":155,"category_name":30,"create_tm":181},672785,"COMP 10261 - The OpenAI Chat Completion API","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229989617427/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=whaJ6wLzLAv42tru8VndtnG7YRQ%3D","comp-10261-the-openai-chat-completion-api",1793608150,{"doc_id":183,"doc_title":184,"file_type":70,"home_preview_img_url":185,"slug":186,"view_count":19,"category_name":30,"create_tm":187},687633,"Assistant 2.0 - User Help Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230001263028/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=o2TfuJDHOjhh6bCo2IHVxNIKvA0%3D","assistant-20-user-help-guide",1794084366,{"doc_id":189,"doc_title":190,"file_type":70,"home_preview_img_url":191,"slug":192,"view_count":34,"category_name":30,"create_tm":193},699682,"Release Notes - Version 5.0 - Build 5281 - New Features and Improvements","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010862797/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=vz4BaGQIzxMybIKQdeiQaMpVbOo%3D","release-notes-version-50-build-5281-new-features-and-improvements",1794488889,{"doc_id":195,"doc_title":196,"file_type":70,"home_preview_img_url":197,"slug":198,"view_count":19,"category_name":30,"create_tm":199},691381,"Arduino VENTUNO Q Hardware Products - Intended use and Security model","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230002047462/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=q2i8o3qQTFrVCxmidPHhQqrxxq8%3D","arduino-ventuno-q-hardware-products-intended-use-and-security-model",1794174245,{"doc_id":201,"doc_title":202,"file_type":70,"home_preview_img_url":203,"slug":204,"view_count":205,"category_name":30,"create_tm":206},203304,"PAT3 Release Notes - Version 1.8.17055 - Updates and Bug Fixes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229882559683/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=50HYwH6iNGX06Ke5GgBRcaGOIEg%3D","pat3-release-notes-version-1817055-updates-and-bug-fixes",12,1788559571,{"doc_id":208,"doc_title":209,"file_type":70,"home_preview_img_url":210,"slug":211,"view_count":19,"category_name":30,"create_tm":162},686337,"LAEW Quick Start Guide - Local AI Engaging Workbench","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000731520/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796109899&Signature=M3%2FJskn%2FyoRTL8sKaK5SEp9vink%3D","laew-quick-start-guide-local-ai-engaging-workbench"]