An open API service indexing awesome lists of open source software.

https://github.com/dowhiledev/vibelang

VibeLang is a programming language designed to seamlessly integrate with Large Language Models (LLMs) through native prompt blocks.
https://github.com/dowhiledev/vibelang

c openai programming-language vibe-coding vibelang

Last synced: 2 months ago
JSON representation

VibeLang is a programming language designed to seamlessly integrate with Large Language Models (LLMs) through native prompt blocks.

Awesome Lists containing this project

README

          






VibeLang Icon



[![Tests](https://github.com/dowhiledev/vibelang/actions/workflows/tests.yml/badge.svg)](https://github.com/dowhiledev/vibelang/actions/workflows/tests.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Version](https://img.shields.io/badge/version-0.1.0-brightgreen.svg)](https://github.com/dowhiledev/vibelang)

VibeLang is a statically-typed language designed for natural language interactions with LLM models. It provides a type-safe way to integrate AI capabilities into applications.

## Project Status

- ✅ Milestone 1: Core Compiler Development
- ✅ Milestone 2: Code Generation & C API Exposure
- ✅ Milestone 3: Runtime Library & LLM Integration
- 🔄 Milestone 4: Cross-Language Support and Wrappers
- 🔄 Milestone 5: Comprehensive Testing and Documentation

## Documentation

The API reference and developer documentation are available [Here](https://dowhiledev.github.io/vibelang/).

You can also generate the documentation locally using:
```bash
make docs
```

And view it by running:
```bash
make serve-docs
```

## Features

- Statically typed language with semantic meaning support
- Direct integration with LLM providers
- Natural language prompt templates
- Type-safe API for C and Python

## Runtime Library

The VibeLang runtime provides:

1. **LLM Connection**: Connect to various LLM providers (currently supports OpenAI)
2. **Prompt Execution**: Send prompts to LLMs with automatic variable substitution
3. **Module Loading**: Dynamically load and execute compiled VibeLang modules

### Configuration

LLM settings can be configured in a `vibeconfig.json` file:

```json
{
"global": {
"provider": "OpenAI",
"api_key": "YOUR_API_KEY_HERE",
"default_params": {
"model": "gpt-3.5-turbo",
"temperature": 0.7,
"max_tokens": 150
}
}
}
```

API keys can also be provided via environment variables:
- `OPENAI_API_KEY` - For OpenAI API access
- `VIBELANG_API_KEY` - Generic API key for any provider

## Getting Started

### Prerequisites

- C compiler (GCC or Clang)
- CMake 3.10+
- libcurl and cJSON development libraries
- Bison and Flex (for building the parser)

### Installation

```bash
git clone https://github.com/dowhiledev/vibelang.git
cd vibelang
mkdir build && cd build
cmake ..
make
sudo make install
```

### Writing Your First VibeLang Program

Create a file named `weather.vibe`:

```
type Temperature = Meaning("temperature in Celsius");
type Forecast = Meaning("weather forecast description");

fn getTemperature(city: String) -> Temperature {
prompt "What is the current temperature in {city} in Celsius?";
}

fn getForecast(city: String, day: String) -> Forecast {
prompt "Provide a brief weather forecast for {city} on {day}.";
}
```

Compile it and integrate the generated C file into your own program:

```bash
vibec weather.vibe
# weather.c contains the generated functions
# compile it together with your application code
gcc -o weather_app my_app.c weather.c -lvibelang
# vibec also produces weather.so for dynamic loading
```

The runtime automatically initializes itself the first time a generated
function executes. You can still call `vibe_runtime_init()` manually to check
for errors or override configuration, but it's optional for simple programs:

```c
#include

int main() {
// Manual initialization is optional
vibe_runtime_init();

/* call generated functions here */

// The runtime is automatically shut down at program exit
return 0;
}
```

The system needs to locate `libvibelang` at runtime. Either install it in a
standard library path, set the environment variable `LD_LIBRARY_PATH` (or
`DYLD_LIBRARY_PATH` on macOS) to include the installation directory, or compile
with an rpath:

```bash
gcc -o weather_app my_app.c weather.c -lvibelang \
-Wl,-rpath,/usr/local/lib
```
Replace `/usr/local/lib` with the prefix used during installation.

## Known Issues

- Function overloading is not yet supported
- Limited error reporting from LLM providers
- No streaming support for LLM responses yet

## VS Code Extension

A minimal VS Code extension is included in the `vscode` directory. It provides
syntax highlighting for `.vibe` files. To try it out:

1. Open the `vscode` folder in VS Code.
2. Press `F5` to launch an Extension Development Host.
3. Open a VibeLang source file to see the highlighting.

## License

This project is licensed under the MIT License - see the LICENSE file for details.