Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion functions/ask.fish
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function ask -a query
set system_prompt "$system_prompt\n\nYou respond to questions in markdown format. You have been asked: $query"

set response_text ""
set -l response_file (mktemp)

if set -q _flag_markdown
set ai_response (curl -s -X POST http://localhost:11434/api/generate \
Expand Down Expand Up @@ -121,7 +122,7 @@ function ask -a query
set done (echo $line | jq -r '.done')

if test -n "$response"
set response_text "$response_text$response"
echo -n "$response" >> $response_file
echo -n (echo "$response" | sed 's/\\n/\n/g') # Stream the response with newlines
end

Expand All @@ -131,6 +132,7 @@ function ask -a query
end

echo "" # Print a newline at the end
set response_text (cat $response_file)
end

# Save conversation to memory (unless --no-memory flag is set)
Expand All @@ -149,4 +151,7 @@ function ask -a query
__track_interaction --failure 2>/dev/null
end
end

# Clean up temp file
rm -f $response_file
end
Loading