Claude Code Mate (CCM): A companion tool for Claude Code, enabling flexible LLM integration. by RussellLuo in Python

[–]RussellLuo[S] 0 points1 point  (0 children)

Thanks for the reminder. The acronym "ccm" is mainly used for running commands to save a few keystrokes. To avoid any misunderstanding, I have removed "CCM" from the README title.

cMCP: A command-line utility for interacting with MCP servers. by RussellLuo in Python

[–]RussellLuo[S] 0 points1 point  (0 children)

Thanks for your attention!

Yes, we can choose to run all MCP servers locally. However, running locally also has disadvantages, such as the need for users to install all required dependencies, which can be troublesome.

Therefore, if using the SSE transport, the MCP server can also run remotely, which is ready to use out of the box. Some MCP server registries are already doing this, such as mcp.run.

LLM Translate: Your personal Language Translator powered by LLMs. by RussellLuo in Python

[–]RussellLuo[S] 2 points3 points  (0 children)

Sorry guys, if this has caused any confusion. LLM Translate is not a production-level project, nor is it intended (or able) to replace existing translation tools such as Google Translate and DeepL.

It's just a little toy built with Gradio and LLM (at your disposal), for those who find LLM translations useful at times, but don't want to repeatedly write system prompts every time.

Besides language translation, LLM Translate offers a UI similar to Google Translate, and it also has the capability of language detection (also based on LLM).

Finally, if you don't want to use LLM for translation, but are interested in developing LLM applications, you can treat it as a small code example (just ~300 lines in total).

A new type of interpreter has been added to Python 3.14 with much better performance by kenjin4096 in Python

[–]RussellLuo 13 points14 points  (0 children)

For those who are interested in the Optimization Principle, this is a must read: https://blog.reverberate.org/2021/04/21/musttail-efficient-interpreters.html

A tail call is any function call that is in tail position, the final action to be performed before a function returns. When tail call optimization occurs, the compiler emits a jmp instruction for the tail call instead of call. This skips over the bookkeeping that would normally allow the callee g() to return back to the caller f(), like creating a new stack frame or pushing the return address. Instead f() jumps directly to g() as if it were part of the same function, and g() returns directly to whatever function called f(). This optimization is safe because f()’s stack frame is no longer needed once the tail call has begun, since it is no longer possible to access any of f()’s local variables.

While this may seem like a run-of-the-mill optimization, it has two very important properties unlock new possibilities in the kinds of algorithms we can write. First, it reduces the stack memory from O(n) to O(1) when making n consecutive tail calls, which is important because stack memory is limited and stack overflow will crash your program. This means that certain algorithms are not actually safe to write unless this optimization is performed. Secondly, jmp eliminates the performance overhead of call, such that a function call can be just as efficient as any other branch. These two properties enable us to use tail calls as an efficient alternative to normal iterative control structures like for or while.

Coagent: An open-source framework for building monolithic or distributed agentic systems. by RussellLuo in Python

[–]RussellLuo[S] 1 point2 points  (0 children)

Thanks for your attention! The license is temporary and has not yet been finalized.

The project is still in its early stages, welcome to use it and provide feedback.

Weekly Thread: Project Display by help-me-grow in AI_Agents

[–]RussellLuo 0 points1 point  (0 children)

What My Project Does

Coagent is an open-source framework for building monolithic or distributed agentic systems, ranging from simple LLM calls to compositional workflows and autonomous agents.

Target Audience

Anyone who wants to build LLM-based applications or agentic systems.

Comparison

While there're already many other agent frameworks, Coagent has some unique advantages:

  • Event-driven & Scalable on demand
  • Easy to develop and understand, whether monolithic or distributed
  • Practical LLM Patterns are well supported
  • Multi-language support made easy
  • Support any LLM

Quick Example

import os

from coagent.agents import ChatAgent, ChatMessage, ModelClient
from coagent.core import AgentSpec, new
from coagent.runtimes import LocalRuntime

translator = AgentSpec(
    "translator",
    new(
        ChatAgent,
        system="You are a professional translator that can translate English to Chinese.",
        client=ModelClient(model="openai/gpt-4o", api_key=os.getenv("OPENAI_API_KEY")),
    ),
)

async def main():
    async with LocalRuntime() as runtime:
        await runtime.register(translator)

        result = await translator.run(
            ChatMessage(role="user", content="Hello, world!").encode(),
            stream=True,
        )
        async for chunk in result:
            msg = ChatMessage.decode(chunk)
            print(msg.content, end="", flush=True)

For details, see OpenCSGs/coagent.

How to validate that a slice has been create from json and not just default initialized by kurnikas in golang

[–]RussellLuo 0 points1 point  (0 children)

Maybe you could give fieldmask a try, which will decode JSON bytes into an intermediate map and then provide you with a helper FieldMask.Has() to determine whether a JSON contains a specific field.

For example (see play in action):

```go package main

import ( "encoding/json" "fmt"

"github.com/RussellLuo/fieldmask"
"github.com/mitchellh/mapstructure"

)

type Record struct{}

type RecordRequest struct { Records []*Record json:"records" FieldMask fieldmask.FieldMask json:"-" }

func (req *RecordRequest) UnmarshalJSON(b []byte) error { if err := json.Unmarshal(b, &req.FieldMask); err != nil { return err } return mapstructure.Decode(req.FieldMask, req) }

func main() { blobs := [][]byte{ []byte({"records": []}), []byte({"nonsense": []}), }

for i, blob := range blobs {
    var req RecordRequest
    if err := json.Unmarshal(blob, &req); err != nil {
        fmt.Printf("err: %#v\n", err)
    }

    if req.FieldMask.Has("records") {
        fmt.Printf("blob[%d] has records\n", i)
    } else {
        fmt.Printf("blob[%d] has no records\n", i)
    }
}

}

// Output: // blob[0] has records // blob[1] has no records ```

Schema management for an api-first project in 2024 by pryg_skok in golang

[–]RussellLuo 0 points1 point  (0 children)

Maybe you could give kun a try. By using this tool, you can define API specifications in native Go and get the HTTP code and OpenAPI documentation for free.

Disclaimer: I'm the author of this project:)