Skip to content

akawaka/copilot-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Akawaka Copilot Bridge

A Symfony bridge that integrates GitHub Copilot AI models into your applications.

License: MIT PHP Version

โœจ Features

  • ๐Ÿš€ Easy Integration - Drop-in Symfony bridge for GitHub Copilot
  • ๐ŸŽฏ Multiple Models - Support for Claude, GPT, Gemini, and more
  • ๐Ÿ” Secure Authentication - Built-in OAuth device flow
  • ๐Ÿ“ Console Commands - Ready-to-use CLI commands

๐Ÿ“ฆ Installation

Install the bridge using Composer:

composer require akawaka/copilot-bridge

That's it! The bridge automatically registers its services and commands.

๐Ÿ—๏ธ Available Models

The bridge provides access to multiple AI model families:

๐Ÿง  Claude Models

use Akawaka\Bridge\Copilot\Copilot;

// Latest Claude models
Copilot::CLAUDE_35_SONNET    // claude-3.5-sonnet
Copilot::CLAUDE_37_SONNET    // claude-3.7-sonnet
Copilot::CLAUDE_OPUS_4       // claude-opus-4

๐Ÿค– GPT Models

// GPT family models
Copilot::GPT_5              // gpt-5
Copilot::GPT_5_MINI         // gpt-5-mini
Copilot::GPT_4O             // gpt-4o
Copilot::O3                 // o3
Copilot::O3_MINI            // o3-mini

๐Ÿ”ฎ Gemini Models

// Google Gemini models
Copilot::GEMINI_20_FLASH    // gemini-2.0-flash-001
Copilot::GEMINI_25_PRO      // gemini-2.5-pro

๐Ÿš€ Quick Start

1. Authentication

First, authenticate with GitHub Copilot:

php bin/console copilot:auth

Follow the prompts to complete OAuth authentication.

2. Using Models in Code

use Akawaka\Bridge\Copilot\Copilot;
use Akawaka\Bridge\Copilot\PlatformFactory;
use Symfony\Component\HttpClient\HttpClient;

// Create a model instance
$model = new Copilot(Copilot::GPT_5_MINI, [
    'temperature' => 0.7,
    'max_tokens' => 1000
]);

// Create the platform
$httpClient = HttpClient::create();
$platform = PlatformFactory::create($httpClient);

// Send a prompt
$messages = new MessageBag(Message::ofUser('Hello, how are you?'));
$result = $platform->invoke($model, $messages);

echo $result->asText();

3. Using with Dependency Injection

# config/services.yaml
services:
    App\Service\MyAIService:
        arguments:
            $copilotAuthService: '@Akawaka\Bridge\Copilot\Auth\CopilotAuthService'
            $platformFactory: '@Akawaka\Bridge\Copilot\PlatformFactory'
// src/Service/MyAIService.php
use Akawaka\Bridge\Copilot\Auth\CopilotAuthService;
use Akawaka\Bridge\Copilot\Copilot;
use Akawaka\Bridge\Copilot\PlatformFactory;

class MyAIService
{
    public function __construct(
        private CopilotAuthService $authService,
        private PlatformFactory $platformFactory
    ) {}
    
    public function askQuestion(string $question): string
    {
        $model = new Copilot(Copilot::CLAUDE_35_SONNET);
        $platform = $this->platformFactory->create($this->httpClient);
        
        $messages = new MessageBag(Message::ofUser($question));
        $result = $platform->invoke($model, $messages, [
            'copilot_access_token' => $this->authService->getAccessToken()
        ]);
        
        return $result->asText();
    }
}

โš™๏ธ Configuration

Basic Configuration

The bridge works out-of-the-box with default settings. For custom configuration:

# config/packages/copilot.yaml
copilot:
    client_id: 'your-github-app-client-id'
    auth_token_expiration: 90  # days
    models:
        custom_model:
            capabilities: ['input_messages', 'output_text']
            options:
                temperature: 0.5
                max_tokens: 2000

๐Ÿ–ฅ๏ธ Console Commands

The bridge provides three console commands:

copilot:auth - Authentication

# Basic authentication
php bin/console copilot:auth

# With custom timeout
php bin/console copilot:auth --timeout=600

# Check existing token first
php bin/console copilot:auth --check-existing

copilot:status - Check Status

php bin/console copilot:status

copilot:logout - Remove Tokens

php bin/console copilot:logout

๐Ÿ”ง Advanced Usage

Custom Model Options

$model = new Copilot(Copilot::CLAUDE_35_SONNET, [
    'temperature' => 0.8,        // Creativity level (0-1)
    'max_tokens' => 2000,        // Maximum response length
    'top_p' => 0.9,              // Nucleus sampling
    'frequency_penalty' => 0.1,   // Reduce repetition
    'presence_penalty' => 0.1     // Encourage new topics
]);

Streaming Responses

use Symfony\AI\Platform\Message\MessageBag;
use Symfony\AI\Platform\Message\Message;

$messages = new MessageBag(Message::ofUser('Tell me a story'));
$result = $platform->invoke($model, $messages, [
    'stream' => true,
    'copilot_access_token' => $accessToken
]);

// Handle streaming response
foreach ($result->stream() as $chunk) {
    echo $chunk->getContent();
}

Error Handling

use Akawaka\Bridge\Copilot\Exception\CopilotException;
use Akawaka\Bridge\Copilot\Exception\AuthenticationException;

try {
    $result = $platform->invoke($model, $messages);
    return $result->asText();
} catch (AuthenticationException $e) {
    // Handle authentication errors
    throw new \RuntimeException('Please run: php bin/console copilot:auth');
} catch (CopilotException $e) {
    // Handle other Copilot errors
    throw new \RuntimeException('Copilot error: ' . $e->getMessage());
}

๐Ÿ“‹ Model Capabilities

Different models support different capabilities:

Model Family Text Input Image Input Streaming Tool Calling
Claude โœ… โœ… โœ… โœ…
GPT โœ… โœ… โœ… โœ…
Gemini โœ… โœ… โœ… โœ…

๐Ÿงช Testing

The bridge includes comprehensive tests:

# Run tests
./vendor/bin/phpunit

# Run with coverage
./vendor/bin/phpunit --coverage-html coverage

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'Add feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Open a Pull Request

๐Ÿ“„ License

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

๐Ÿ†˜ Support

๐Ÿ™ Acknowledgments


Made with โค๏ธ by Franck Matsos

About

Bridge to Github Copilot for Symfony

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages