diff --git a/menu/navigation.json b/menu/navigation.json index 467f504a6c..42f66c5d5e 100644 --- a/menu/navigation.json +++ b/menu/navigation.json @@ -956,18 +956,6 @@ { "label": "Data privacy", "slug": "data-privacy" - }, - { - "label": "Adding AI to VS Code using Continue", - "slug": "adding-ai-to-vscode-using-continue" - }, - { - "label": "Adding AI to IntelliJ IDEA using Continue", - "slug": "adding-ai-to-intellij-using-continue" - }, - { - "label": "Integrating Generative APIs with popular AI tools", - "slug": "integrating-generative-apis-with-popular-tools" } ], "label": "Additional Content", diff --git a/pages/generative-apis/how-to/query-code-models.mdx b/pages/generative-apis/how-to/query-code-models.mdx index c58612e2c7..b81e329d51 100644 --- a/pages/generative-apis/how-to/query-code-models.mdx +++ b/pages/generative-apis/how-to/query-code-models.mdx @@ -1,13 +1,13 @@ --- meta: - title: How to query code models with Scaleway's Generative APIs - description: Learn how to interact with powerful code models using Scaleway's Generative APIs service. Integrate with VS Code and IntelliJ for enhanced coding experience. + title: How to query code models + description: Learn how to interact with powerful language models specialized in code using Scaleway's Generative APIs service. content: - h1: How to query code models with Scaleway's Generative APIs - paragraph: Scaleway's Generative APIs service allows users to interact with powerful code models hosted on the platform. These code models are specialized in understanding code, generating code, and fixing code. With Scaleway's Generative APIs, you can integrate these code models with popular IDEs like VS Code and IntelliJ. -tags: generative-apis ai-data language-models code-models chat-completions-api scaleway-continue vs-code intellij + h1: How to query code models + paragraph: Learn how to interact with powerful language models specialized in code using Scaleway's Generative APIs service. +tags: generative-apis ai-data language-models code-models chat-completions-api dates: - validation: 2025-02-14 + validation: 2024-12-09 posted: 2024-12-09 --- @@ -28,100 +28,35 @@ Code models are also ideal AI assistants when **added to IDEs** (integrated deve - A Scaleway account logged into the [console](https://console.scaleway.com) - [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization - A valid [API key](/iam/how-to/create-api-keys/) for API authentication -- Python 3.7+ installed on your system - An IDE such as Visual Studio Code or JetBrains -### Querying code models with Scaleway's Generative APIs - -1. Set up the OpenAI Python SDK: - - Install the SDK by running: - ```bash - pip install openai - ``` - - Configure the SDK with your API key and Scaleway's API base URL: - ```python - from openai import OpenAI - - client = OpenAI( - base_url="https://api.scaleway.ai/v1", - api_key="###SCW_SECRET_KEY###" - ) - ``` - Replace `"###SCW_SECRET_KEY###"` with your actual API secret key. - -2. Make an API request: - - To generate code or receive assistance, send a request to the chat completion endpoint: - ```python - completion = client.chat.completions.create( - model="qwen2.5-coder-32b-instruct", - messages=[{"role": "user", "content": "Write a Python function to sort a list using quicksort."}], - temperature=0.7, - max_tokens=150 - ) - - print(completion.choices[0].message.content) - ``` - This will generate a Python function implementing the quicksort algorithm. - - -## Integrating Continue in VS Code and JetBrains IntelliJ - -[Continue](https://www.continue.dev/) is an open-source code assistant that connects AI models to your IDE. It is available for Visual Studio Code (VS Code) and JetBrains IntelliJ: - -* [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=Continue.continue) -* [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/22707-continue) - -### Installation of Continue - -#### For Visual Studio Code - -1. Open VS Code and navigate to the **Extensions** view (`Ctrl+Shift+X`). -2. Type `Continue` in the search bar and click **Install**. -3. The **Continue** icon should appear on the sidebar. - -#### For JetBrains IntelliJ - -1. Open your JetBrains IDE and go to **Settings** (`Ctrl+Alt+S`). -2. Select **Plugins** and search for `Continue` in the marketplace. -3. Click **Install**. The `Continue` icon should appear on the toolbar. - -### Configuration of Continue - -1. Locate the configuration file. The `config.json` file is typically found at: - - `~/.continue/config.json` on Linux/macOS - - `%USERPROFILE%\.continue\config.json` on Windows - -2. Configure Continue to use Scaleway's API: - - Add the following configuration: - ```json - { - "models": [ - { - "model": "qwen2.5-coder-32b-instruct", - "title": "Qwen2.5-coder", - "provider": "scaleway", - "apiKey": "###SCW_SECRET_KEY###" - } - ] - } - ``` - - Read more about how to set up your `config.json` on the [official Continue documentation](https://docs.continue.dev/reference). - -3. Restart your IDE after you have modified and saved the configuration file. -4. Open the **Command Palette** in VS Code by pressing `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac) and type `Continue` to access the extension's features. +## Install Continue in your IDE - - Refer to our dedicated documentation for detailed information on how to integrate Continue in your favourite IDE. - - [Integrating Continue Dev with Visual Studio Code](/generative-apis/reference-content/adding-ai-to-vscode-using-continue/) - - [Integrating Continue Dev with IntelliJ IDEA](/generative-apis/reference-content/adding-ai-to-intellij-using-continue/) - +[Continue](https://www.continue.dev/) is an [open-source code assistant](https://github.com/continuedev/continue) to connect AI models to your IDE. + +To get Continue, simply hit `install` in your IDE's marketplace: +- [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=Continue.continue) +- [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/22707-continue) + +## Configure Scaleway as an API provider in Continue -### Using Continue with your IDE -Continue can be used with VS Code to automate tasks, generate code, and enhance your coding experience. Here are some examples of how to use Continue with VS Code: +Continue's `config.json` file will set models and providers allowed for chat, autocompletion etc. +Here is an example configuration with Scaleway's OpenAI-compatible provider: -* Code generation: Use the `Continue: Generate Code` command to generate boilerplate code, functions, or entire classes. -* Code completion: Use the `Continue: Complete Code` command to complete partially written code. -* Code refactoring: Use the `Continue: Refactor Code` command to refactor code and improve its readability and maintainability. +```json +"models": [ + { + "model": "qwen2.5-coder-32b-instruct", + "title": "Qwen2.5-coder", + "provider": "scaleway", + "apiKey": "###SCW SECRET KEY###" + } +] +``` + + + The config.json file is typically stored as `~/.continue/config.json` on Linux/macOS systems, and `%USERPROFILE%\.continue\config.json` on Windows. + +Read more about how to set up your `config.json` on the [official Continue documentation](https://docs.continue.dev/reference). diff --git a/pages/generative-apis/reference-content/adding-ai-to-intellij-using-continue.mdx b/pages/generative-apis/reference-content/adding-ai-to-intellij-using-continue.mdx deleted file mode 100644 index cd55abc343..0000000000 --- a/pages/generative-apis/reference-content/adding-ai-to-intellij-using-continue.mdx +++ /dev/null @@ -1,120 +0,0 @@ ---- -meta: - title: Adding AI to IntelliJ IDEA using Continue and Generative APIs - description: Learn how to integrate AI-powered code models into IntelliJ IDEA with Continue and Scaleway's Generative APIs. -content: - h1: Adding AI to IntelliJ IDEA using Continue and Generative APIs - paragraph: Improve your coding efficiency by integrating AI-powered code models into IntelliJ IDEA. With Continue and Scaleway's Generative APIs, you can use AI to understand, generate, and optimize code. -tags: generative-apis, ai, machine-learning, language-models, code-assistance, intellij-idea, continue -validation_date: 2025-02-14 -posted_date: 2025-02-14 ---- - -AI-driven coding is revolutionizing software development by automating repetitive tasks, generating code snippets, improving code quality, and identifying potential bugs. -By integrating AI-powered tools, developers can significantly enhance productivity and optimize workflows. -This guide will help you integrate AI-powered code models into JetBrain's IntelliJ IDEA using Continue and Scaleway’s Generative APIs. - - - -- A Scaleway account logged into the [console](https://console.scaleway.com) -- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization -- A valid [API key](/iam/how-to/create-api-keys/) for API authentication -- Installed [IntelliJ IDEA](https://www.jetbrains.com/idea/) on your local machine. - -## Install Continue in IntelliJ IDEA - -You can install Continue from the [JetBrains marketplace](https://plugins.jetbrains.com/plugin/22707-continue): - -1. Open IntelliJ IDEA and go to **Preferences** (`Ctrl+Alt+S` on Windows/Linux, `Cmd+,` on macOS). -2. Navigate to **Plugins**, then click **Marketplace**. -3. Search for **Continue** and click **Install**. -4. Restart IntelliJ IDEA after installation. - -### Configure Continue to use Scaleway’s Generative APIs - -To link Continue with Scaleway’s Generative APIs, you need to configure the settings file: - -1. Locate your Continue configuration directory: - - **Linux/macOS**: `~/.continue/` - - **Windows**: `%USERPROFILE%\.continue\` -2. Create a `config.json` file inside this directory. -3. Add the following configuration: - ```json - { - "models": [ - { - "model": "qwen2.5-coder-32b-instruct", - "title": "Qwen2.5 Coder", - "provider": "scaleway", - "apiKey": "###SCW_SECRET_KEY###" - } - ] - } - ``` -4. Save the file and restart IntelliJ IDEA. - - - For more details on configuring `config.json`, refer to the [official Continue documentation](https://docs.continue.dev/reference). - - -### Activate Continue in IntelliJ IDEA - -After configuring the API, activate Continue in IntelliJ IDEA: - -- Open the **Command Search** (`Shift+Shift` on Windows/Linux/macOS). -- Type `"Continue"` and select the appropriate command to enable AI-powered assistance. - -## Using Continue for AI-powered coding - -Once Continue is configured, you can leverage AI capabilities to streamline development. Below are some key features: - -### AI-assisted code generation - -Use the `Continue: Generate Code` command to generate boilerplate code, functions, or even entire classes based on natural language prompts. - -#### Example: - -- Input Prompt: *"Create a Java method to validate an email address."* -- AI-generated output: - ```java - import java.util.regex.Pattern; - - public class EmailValidator { - private static final String EMAIL_REGEX = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$"; - private static final Pattern pattern = Pattern.compile(EMAIL_REGEX); - - public static boolean isValidEmail(String email) { - return pattern.matcher(email).matches(); - } - } - ``` - -### Intelligent code completion - -Continue enhances your coding workflow with AI-driven code completion. Simply start typing, and the AI model will suggest and complete your code efficiently. - -### Automated code refactoring - -Refactoring is crucial for maintaining clean and efficient code. Use the `Continue: Refactor Code` command to enhance readability and optimize performance. - -#### Example - -- Before refactoring: - ```java - public int calculateSum(int a, int b) { - int result = a + b; - return result; - } - ``` - -- After AI-driven refactoring: - ```java - public int calculateSum(int a, int b) { - return a + b; - } - ``` - -## Conclusion - -By integrating Continue with Scaleway’s Generative APIs, you unlock AI-powered coding capabilities that enhance productivity, automate repetitive tasks, and improve code quality. - diff --git a/pages/generative-apis/reference-content/adding-ai-to-vscode-using-continue.mdx b/pages/generative-apis/reference-content/adding-ai-to-vscode-using-continue.mdx deleted file mode 100644 index 898dd6bf8c..0000000000 --- a/pages/generative-apis/reference-content/adding-ai-to-vscode-using-continue.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -meta: - title: Adding AI to VS Code using Continue and Generative APIs - description: Learn how to integrate AI-powered code models into VS Code with Continue and Scaleway's Generative APIs. -content: - h1: Adding AI to VS Code using Continue and Generative APIs - paragraph: Elevate your coding experience by integrating AI-powered code models into VS Code. With Continue and Scaleway's Generative APIs, you can leverage AI to understand, generate, and optimize code with ease. -tags: generative-apis, ai, machine-learning, language-models, code-assistance, vs-code, continue -validation_date: 2025-02-14 -posted_date: 2025-02-14 ---- - -AI-powered coding is transforming software development by automating repetitive tasks, generating code, improving code quality, and even detecting and fixing bugs. By integrating AI-driven tools, developers can significantly boost productivity and streamline their workflows. -This guide provides a step-by-step guide on how to integrate AI-powered code models into VS Code using Continue and Scaleway's Generative APIs. - - - -- A Scaleway account logged into the [console](https://console.scaleway.com) -- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization -- A valid [API key](/iam/how-to/create-api-keys/) for API authentication -- Installed [Visual Studio Code](https://code.visualstudio.com/) on your local machine - -## Install Continue in VS Code - -You can install Continue directly from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=Continue.continue) or via the command line: - -```bash -code --install-extension continue.continue -``` - -### Configure Continue to use Scaleway’s Generative APIs - -To link Continue with Scaleway's Generative APIs, you need to configure a settings file: - -- Create a `config.json` file inside your `.continue` directory. -- Add the following configuration to enable Scaleway's Generative API: - ```json - { - "models": [ - { - "model": "qwen2.5-coder-32b-instruct", - "title": "Qwen2.5 Coder", - "provider": "scaleway", - "apiKey": "###SCW_SECRET_KEY###" - } - ] - } - ``` -- Save the file at the correct location: - - Linux/macOS: `~/.continue/config.json` - - Windows: `%USERPROFILE%\.continue\config.json` - - - For more details on configuring `config.json`, refer to the [official Continue documentation](https://docs.continue.dev/reference). - - -### Activate Continue in VS Code - -After configuring the API, open VS Code and activate Continue: - -- Open the **Command Palette** (`Ctrl+Shift+P` on Windows/Linux, `Cmd+Shift+P` on Mac) -- Type `"Continue"` and select the appropriate command to enable AI-powered assistance. - -## Using Continue for AI-powered coding - -Once Continue is configured, you can leverage AI capabilities to streamline development. Below are some key features: - -### AI-assisted code generation - -Use the "Continue: Generate Code" command to generate boilerplate code, functions, or even entire classes based on natural language prompts. - -#### Example - -- Input prompt: *"Create a Python function to merge two sorted lists"* -- AI-Generated output: - ```python - def merge_sorted_lists(list1, list2): - return sorted(list1 + list2) - ``` - -### Intelligent code completion - -Continue enhances your coding workflow with AI-driven code completion. Simply start typing, and the AI model will predict and complete your code. - -### Automated code refactoring - -Refactoring is essential for maintaining clean and efficient code. Use the *"Continue: Refactor Code"* command to improve readability and optimize performance. - -#### Example - -- Before refactoring: - ```python - def add_numbers(a, b): - result = a + b - return result - ``` - -- After AI-driven refactoring: - ```python - def add_numbers(a, b): - return a + b - ``` - -## Conclusion - -By integrating Continue with Scaleway’s Generative APIs, you unlock AI-powered coding capabilities that enhance productivity, automate repetitive tasks, and improve code quality. \ No newline at end of file diff --git a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx b/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx deleted file mode 100644 index 25ab4fe564..0000000000 --- a/pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx +++ /dev/null @@ -1,243 +0,0 @@ ---- -meta: - title: Integrating Scaleway Generative APIs with popular AI tools - description: Learn how to integrate Scaleway's Generative APIs with popular AI tools to unlock the full potential of your applications. -content: - h1: Integrating Scaleway Generative APIs with popular AI tools - paragraph: Scaleway's Generative APIs provide a powerful way to integrate AI capabilities into your applications. By leveraging our APIs, you can tap into the latest advancements in natural language processing, computer vision, and more. In this guide, we'll show you how to integrate Scaleway's Generative APIs with popular AI tools like LangChain, LlamaIndex, and OpenAI. -tags: generative-apis, ai, language-models -dates: - validation: 2025-02-18 - posted: 2025-02-18 ---- - -Scaleway's Generative APIs are designed to provide easy access to the latest AI models and techniques. Our APIs are built on top of a robust infrastructure that ensures scalability, reliability, and security. With our APIs, you can integrate AI capabilities into your applications, such as text generation, image classification, and more. - -## Comparison of AI tools and libraries - -The following table compares AI tools and libraries supported by Scaleway's Generative APIs: - -| Tool/Library | Description | Use cases | Integration effort | -| --- | --- | --- | --- | -| [OpenAI](#openai-compatible-libraries) | Popular AI library for natural language processing | Text generation, language translation, text summarization | Low | -| [LangChain](#langchain-rag-and-llm-applications) | Library for building AI applications | Inference, embeddings, document indexing and retrieval | Medium | -| [LlamaIndex](#llamaindex-document-indexing-and-retrieval) | Library for indexing and retrieving documents using AI models | Document indexing and retrieval, question answering | Medium | -| [Continue Dev](#continue-dev-ai-coding-assistance) | Library for AI-powered coding assistance | Code completion, code review | Low | -| [Transformers (Hugging Face)](#transformers-hugging-face-integration) | Library for pre-trained models for natural language processing | Text generation, language translation, text summarization | Medium | -| [cURL/Python](#api-clients-and-custom-integrations) | Direct API clients for custom integrations | Custom applications, data processing | High | - - - The integration effort is subjective and may vary depending on the specific use case and requirements. - - -## OpenAI-compatible libraries - -Scaleway Generative APIs follow OpenAI's API structure, making integration straightforward. To get started, you'll need to install the OpenAI library and set up your API key. - -### Configuration - -To use the OpenAI library with Scaleway's Generative APIs, you'll need to set the API key and base URL in your OpenAI-compatible client: -```python -import openai -openai.api_key = "" -openai.api_base = "https://api.scaleway.ai/v1" -response = openai.ChatCompletion.create( - model="llama-3.1-8b-instruct", - messages=[{"role": "user", "content": "Tell me a joke about AI"}] -) -print(response["choices"][0]["message"]["content"]) -``` - - Make sure to replace `` with your actual API key. - - -### Using OpenAI for text generation - -To use OpenAI for text generation, you can create a `ChatCompletion` object and call the `create` method: -```python -response = openai.ChatCompletion.create( - model="llama-3.1-8b-instruct", - messages=[{"role": "user", "content": "Tell me a joke about AI"}] -) -print(response["choices"][0]["message"]["content"]) -``` - -## LangChain (RAG & LLM applications) - -LangChain is a popular library for building AI applications. Scaleway's Generative APIs support LangChain for both inference and embeddings. - -### Configuration - -To use LangChain with Scaleway's Generative APIs, you'll need to install the required dependencies: -```bash -pip install langchain langchain_openai langchain_postgres psycopg2 -``` -Next, set up the API connection: -```python -from langchain_openai import OpenAIEmbeddings, ChatOpenAI -import os -os.environ["OPENAI_API_KEY"] = "" -os.environ["OPENAI_API_BASE"] = "https://api.scaleway.ai/v1" -llm = ChatOpenAI(model="llama-3.1-8b-instruct") -embeddings = OpenAIEmbeddings(model="bge-multilingual-gemma2") -``` - - Make sure to replace `` with your actual API key. - - -### Using LangChain for inference - -To use LangChain for inference, you can create a `ChatOpenAI` object and call the `ask` method: -```python -response = llm.ask("What is the capital of France?") -print(response) -``` -### Using LangChain for embeddings - -To use LangChain for embeddings, you can create an `OpenAIEmbeddings` object and call the `compute_embeddings` method: -```python -embeddings = OpenAIEmbeddings(model="bge-multilingual-gemma2") -text = "This is an example sentence." -embedding = embeddings.compute_embeddings(text) -print(embedding) -``` -## LlamaIndex (document indexing & retrieval) - -LlamaIndex is a library for indexing and retrieving documents using AI models. Scaleway's Generative APIs support LlamaIndex for document indexing and retrieval. - -### Configuration - -To use LlamaIndex with Scaleway's Generative APIs, you'll need to install the required dependencies: -```bash -pip install llama-index -``` -Next, set up the embedding model: -```python -from llama_index.embeddings.openai import OpenAIEmbedding -embed_model = OpenAIEmbedding( - api_key="", - api_base="https://api.scaleway.ai/v1", - model="bge-multilingual-gemma2" -) -``` - - Make sure to replace `` with your actual API key. - - -### Indexing documents - -To index documents using LlamaIndex, you'll need to create a `VectorStoreIndex` object and call the `add_documents` method: -```python -from llama_index import VectorStoreIndex, SimpleDirectoryReader -documents = SimpleDirectoryReader("data").load_data() -index = VectorStoreIndex.from_documents(documents, embed_model=embed_model) -``` -### Retrieving documents - -To retrieve documents using LlamaIndex, you can call the `query` method on the `VectorStoreIndex` object: -```python -query_engine = index.as_query_engine() -response = query_engine.query("Summarize this document") -print(response) -``` - -## Continue Dev (AI coding assistance) - -Continue Dev is a library that provides AI-powered coding assistance. Scaleway's Generative APIs support Continue Dev for code completion and more. - - - Refer our dedicated documentation for - - [Integrating Continue Dev with Visual Studio Code](/generative-apis/reference-content/adding-ai-to-vscode-using-continue/) - - [Integrating Continue Dev with IntelliJ IDEA](/generative-apis/reference-content/adding-ai-to-intellij-using-continue/) - - -### Configuration - -To use Continue Dev with Scaleway's Generative APIs, you'll need to modify the `continue.json` file to add Scaleway's API: -```json -{ - "models": [ - { - "title": "Qwen2.5-Coder-32B-Instruct", - "provider": "scaleway", - "model": "qwen2.5-coder-32b-instruct", - "apiKey": "" - } - ], - "embeddingsProvider": { - "provider": "scaleway", - "model": "bge-multilingual-gemma2", - "apiKey": "" - } -} -``` - - Make sure to replace `` with your actual API key. - - -## Transformers (Hugging Face integration) - -Hugging Face's `transformers` library provides a range of pre-trained models for natural language processing. Scaleway's Generative APIs support Hugging Face integration for text generation and more. - -### Configuration - -To use Hugging Face with Scaleway's Generative APIs, you'll need to install the `transformers` library and set up your API key: -```python -from transformers import pipeline -generator = pipeline( - "text-generation", - model="llama-3.1-8b-instruct", - tokenizer="meta-llama/Llama-3-8b", - api_base="https://api.scaleway.ai/v1", - api_key="" -) -``` - - Make sure to replace `` with your actual API key. - - -### Using Hugging Face for text generation - -To use Hugging Face for text generation, you can call the `generator` function: -```python -print(generator("Write a short poem about the ocean")) -``` -## API clients and custom integrations - -You can interact with Scaleway's Generative APIs directly using any HTTP client. - -### cURL example - -To use cURL with Scaleway's Generative APIs, you can use the following command: -```bash -curl https://api.scaleway.ai/v1/chat/completions \ - -H "Authorization: Bearer " \ - -H "Content-Type: application/json" \ - -d '{ - "model": "llama-3.1-8b-instruct", - "messages": [{"role": "user", "content": "What is quantum computing?"}] - }' -``` - - Make sure to replace `` with your actual API key. - - -### Python example - -To use Python with Scaleway's Generative APIs, you can use the following code: -```python -import requests -headers = { - "Authorization": "Bearer ", - "Content-Type": "application/json" -} -data = { - "model": "llama-3.1-8b-instruct", - "messages": [{"role": "user", "content": "Explain black holes"}] -} -response = requests.post("https://api.scaleway.ai/v1/chat/completions", json=data, headers=headers) -print(response.json()["choices"][0]["message"]["content"]) -``` - - Make sure to replace `` with your actual API key. - \ No newline at end of file