Compare commits
2 Commits
c37b7d46b4
...
8d9369c502
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d9369c502 | |||
| 957b8f46c8 |
@@ -0,0 +1,21 @@
|
|||||||
|
# This is "explain.prompt", a slash command to explain code
|
||||||
|
# It is used to define and reuse prompts within Continue
|
||||||
|
# Continue will automatically create a slash command for each prompt in the .prompts folder
|
||||||
|
# To learn more, see the full .prompt file reference: https://docs.continue.dev/walkthroughs/prompt-files
|
||||||
|
temperature: 0.3
|
||||||
|
---
|
||||||
|
<system>
|
||||||
|
You are an expert programmer
|
||||||
|
</system>
|
||||||
|
|
||||||
|
{{{ input }}}
|
||||||
|
|
||||||
|
Please analyze the source code snippet above and provide a detailed explanation of its functionality.
|
||||||
|
|
||||||
|
Input: Clearly identify where the code takes input from (e.g., user input, file, database, API call). Specify the format of this input (e.g., text string, numerical values, JSON object).
|
||||||
|
Processing: Describe step-by-step how the code processes the input. Explain the purpose of each key function, loop, or conditional statement. Use clear and concise language, avoiding jargon where possible.
|
||||||
|
Output: Specify what the code produces as output (e.g., printed text, modified file, database update, API response). Describe the format and content of this output.
|
||||||
|
|
||||||
|
Invocation Context: Who would typically use this code snippet? What is its intended purpose or application? Provide examples of real-world scenarios where this code might be employed.
|
||||||
|
|
||||||
|
If you need to provide more context, please include it in your explanation.
|
||||||
@@ -1,21 +1,35 @@
|
|||||||
# Example function to interact with OLLAMA
|
|
||||||
|
# Import the necessary library from ollama module
|
||||||
from ollama import Client
|
from ollama import Client
|
||||||
|
|
||||||
def get_response(user_query):
|
def get_response(user_query):
|
||||||
|
# Create a client object for interacting with OLLAMA API
|
||||||
client = Client()
|
client = Client()
|
||||||
|
|
||||||
|
# Generate and retrieve the response based on user's query
|
||||||
response = client.generate_response(user_query)
|
response = client.generate_response(user_query)
|
||||||
|
|
||||||
|
# Return the generated response
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Flask endpoint for user interaction
|
# Flask endpoint for user interaction
|
||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
|
|
||||||
|
# Initialize a Flask application
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/smartassist', methods=['POST'])
|
@app.route('/smartassist', methods=['POST'])
|
||||||
def smartassist():
|
def smartassist():
|
||||||
|
# Extract the query from the incoming JSON data
|
||||||
data = request.json
|
data = request.json
|
||||||
user_query = data['query']
|
user_query = data['query']
|
||||||
|
|
||||||
|
# Get the response from the OLLAMA API based on the user's query
|
||||||
response = get_response(user_query)
|
response = get_response(user_query)
|
||||||
|
|
||||||
|
# Return the response as a JSON object in the HTTP response
|
||||||
return jsonify({"response": response})
|
return jsonify({"response": response})
|
||||||
|
|
||||||
|
# Run the Flask application if this script is executed directly
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user