Skip to content

Instantly share code, notes, and snippets.

@josetesan
Created February 22, 2024 15:35
Show Gist options
  • Save josetesan/d3039d05c36055b16663200ae2af9726 to your computer and use it in GitHub Desktop.
Save josetesan/d3039d05c36055b16663200ae2af9726 to your computer and use it in GitHub Desktop.
Use jbang to query Ollama to help you with AI
//DEPS io.quarkus.platform:quarkus-bom:3.7.4@pom
//DEPS io.quarkiverse.langchain4j:quarkus-langchain4j-openai:0.8.3
//Q:CONFIG quarkus.langchain4j.openai.base-url=http://localhost:11434/v1/
//Q:CONFIG quarkus.langchain4j.openai.api-key=ollama
//Q:CONFIG quarkus.langchain4j.openai.chat-model.model-name=gemma
//Q:CONFIG quarkus.langchain4j.openai.timeout=60s
import dev.langchain4j.model.chat.ChatLanguageModel;
import io.vertx.ext.web.Router;
import jakarta.enterprise.event.Observes;
// run with jbang AiApp.java
public class AiApp {
void route(@Observes Router router, ChatLanguageModel ai) {
router.get("/ai").blockingHandler(rc -> rc.end( ai.generate("How can i create a python script that prints current date")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment