langfuse-java icon indicating copy to clipboard operation
langfuse-java copied to clipboard

more example for normal springboot project.

Open Namelesschz opened this issue 9 months ago • 6 comments

Hi Steffen, If don't use spring AI or langchain4j. Can langfuse monitor normal Springboot project. like I use simple api call to LLM. how the langfuse monitor this model. Do your have more example ? many thanks

Namelesschz avatar Apr 03 '25 02:04 Namelesschz

@Namelesschz I think we can provide additional examples or more guidance for spring, yes. It's hard to create representative cases from scratch though. Do you have an existing code snippet that you could share and that we can then instrument? That would help us ensure that our examples are relevant for users like you.

Steffen911 avatar Apr 03 '25 12:04 Steffen911

@Steffen911 sure.

public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
        ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
                .addUserMessage("who are your")
                .model("qwen-plus")
                .build();
        ChatCompletion chatCompletion = client.chat().completions().create(params);
        System.out.println(chatCompletion.choices().get(0).message().content().orElse("not response"));
    }

This is simple example to call the LLM. we use websoceket to build the assistants application.

Namelesschz avatar Apr 07 '25 01:04 Namelesschz

I would also like to see some examples on how to use the prompt management feature with basic examples such as in this overview

cceyda avatar Jul 30 '25 06:07 cceyda

@cceyda Did you try to integrate with prompt management on your own? It should be quite straightforward given the APIs. I don't think we could add those examples soon, but if you give it a shot and contribute an overview on what you did, I'ld love to get them merged here.

Steffen911 avatar Aug 04 '25 07:08 Steffen911

I also need more examples about how to use java api .

fenggangchen-alt avatar Sep 12 '25 08:09 fenggangchen-alt

@fenggangchen-alt Can you share specific questions? What kind of calls do you want to make?

Steffen911 avatar Sep 16 '25 17:09 Steffen911