### Complete Function Calling Implementation Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/foundations/tools.md A full example demonstrating the setup, tool definition, API request, and execution flow. ```js import { OpenAI } from "openai"; const openai = new OpenAI({ baseURL: 'https://docs.liara.ir/baseUrl', apiKey: '', }); function getCurrentWeather(location, unit = "celsius") { return { location: location, temperature: unit === "celsius" ? 35 : 68, // Celsius or Fahrenheit unit: unit, condition: "Sunny" }; } const tools = [{ "type": "function", "function": { "name": "getCurrentWeather", "description": "Get current temperature for a given location.", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "City and country e.g. Bogotá, Colombia" }, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, }, "required": [ "location" ], }, } }]; const messages = [{ role: "user", content: "What is the weather like in Paris today?" }]; const completion = await openai.chat.completions.create({ model: "openai/gpt-4.1", messages: messages, tools, tool_choice: "auto", }); const argsRaw = completion.choices[0].message.tool_calls[0].function.arguments; const args = JSON.parse(argsRaw); const weather = getCurrentWeather( args["location"], args["unit"] || "celsius" ); console.log(`The current weather in ${args.location} is ${weather.temperature}°${weather.unit === "celsius" ? "C" : "F"} and ${weather.condition}.`); ``` -------------------------------- ### Complete Implementation Example Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/foundations/tools.md A full PHP script demonstrating client initialization, tool definition, and function execution. ```php '; $baseUrl = 'https://docs.liara.ir/baseUrl'; $model = 'openai/gpt-4.1'; $client = \OpenAI::factory() ->withApiKey($yourApiKey) ->withBaseUri($baseUrl) ->make(); function get_current_weather($location, $unit = 'celsius') { return [ 'location' => $location, 'temperature' => $unit === 'celsius' ? 35 : 68, 'unit' => $unit, 'condition' => 'Sunny', ]; } $tools = [ [ 'type' => 'function', 'function' => [ 'name' => 'get_current_weather', 'description' => 'Get the current weather in a given location', 'parameters' => [ 'type' => 'object', 'properties' => [ 'location' => [ 'type' => 'string', 'description' => 'The city and state, e.g. San Francisco, CA', ], 'unit' => [ 'type' => 'string', 'enum' => ['celsius', 'fahrenheit'] ], ], 'required' => ['location'], ], ], ] ]; $messages = [ ['role' => 'user', 'content' => "What's the weather like in Tehran today?"] ]; $response = $client->chat()->create([ 'model' => $model, 'messages' => $messages, 'tools' => $tools, 'tool_choice' => 'auto', ]); $args = json_decode($response->choices[0]->message->toolCalls[0]->function->arguments, true); $weather = get_current_weather( $args['location'], $args['unit'] ?? 'celsius' ); echo "The weather in {$weather['location']} is {$weather['temperature']}°" . strtoupper(substr($weather['unit'], 0, 1)) . " and {$weather['condition']}."; ``` -------------------------------- ### Setup Web Directory and Test File Source: https://github.com/liara-cloud/docs/blob/master/public/llms/iaas/debian/how-tos/connect-domain.md Creates the web root directory and adds a basic index.html file for testing. ```bash sudo mkdir -p /var/www/example.com ``` ```bash echo '

It works on Apache!

' | sudo tee /var/www/example.com/index.html ``` -------------------------------- ### Install OpenClaw Source: https://github.com/liara-cloud/docs/blob/master/src/pages/ai/connect-to-service/openclaw.mdx Command to download and execute the OpenClaw installation script. ```powershell iwr -useb https://openclaw.ai/install.ps1 | iex ``` -------------------------------- ### Install Dependencies Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/cookbook/translator-telegrambot.md Installs the necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Clone and Navigate to Project Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/cookbook/translator-telegrambot.md Initializes the project by cloning the repository and entering the specific bot directory. ```bash git clone https://github.com/liara-cloud/ai-sdk-examples.git cd ai-sdk-examples/Telegram-Bot ``` -------------------------------- ### Initialize Project Directory Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/getting-started/nodejs.md Create a new directory and initialize a package.json file to start the project. ```bash mkdir my-ai-app cd my-ai-app pnpm init ``` -------------------------------- ### liara start Source: https://github.com/liara-cloud/docs/blob/master/public/llms/references/cli/start-app.md Starts a stopped application using the Liara CLI. ```APIDOC ## liara start ### Description Starts a stopped application on the Liara platform. ### Usage `liara start [-h] [--debug] [--api-token ] [--account ] [-a ] [--team-id ]` ### Parameters - **-h**: Show help information. - **--debug**: Enable debug mode. - **--api-token **: Specify the API token for authentication. - **--account **: Specify the account to use. - **-a **: Specify the application name. - **--team-id **: Specify the team ID. ``` -------------------------------- ### Complete Function Calling Implementation Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/foundations/tools.md A full example demonstrating client initialization, tool definition, and the complete function calling workflow. ```python from openai import OpenAI import json client = OpenAI( base_url="https://docs.liara.ir/baseUrl", api_key="", ) def get_current_weather(location, unit="celsius"): return { "location": location, "temperature": unit == "celsius" and 35 or 68, # Celsius or Fahrenheit "unit": unit, "condition": "Sunny" } tools = [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA", }, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, }, "required": ["location"], }, } } ] messages = [{"role": "user", "content": "What's the weather in fahrenheit like in Tehran today?"}] completion = client.chat.completions.create( model="openai/gpt-4.1", messages=messages, tools=tools, tool_choice="auto" ) args = json.loads(completion.choices[0].message.tool_calls[0].function.arguments) print(args) weather = get_current_weather( location=args["location"], unit=args.get("unit", "celsius") ) print(f"The weather in {weather['location']} is {weather['temperature']}°{weather['unit'][0].upper()} and {weather['condition']}.") ``` -------------------------------- ### Install Go dependencies Source: https://github.com/liara-cloud/docs/blob/master/src/pages/dbaas/elastic-search/how-tos/connect-via-platform/go.mdx Install the godotenv package to manage environment variables. ```bash go get github.com/joho/godotenv ``` -------------------------------- ### Install Gorilla WebSocket Source: https://github.com/liara-cloud/docs/blob/master/public/llms/paas/go/how-tos/use-websocket.md Install the required Gorilla WebSocket package dependency. ```bash go get -u github.com/gorilla/websocket ``` -------------------------------- ### Initialize Go Project Source: https://github.com/liara-cloud/docs/blob/master/public/llms/paas/go/how-tos/use-websocket.md Create a new Go module for the chat application. ```bash go mod init realtime-chat ``` -------------------------------- ### Install ffmpeg-python Source: https://github.com/liara-cloud/docs/blob/master/public/llms/paas/django/how-tos/use-ffmpeg-module.md Install the required Python wrapper for FFMPEG using pip. ```bash pip install ffmpeg-python ``` -------------------------------- ### Verify OpenSSH Installation Source: https://github.com/liara-cloud/docs/blob/master/public/llms/iaas/details/openssh-package.md Check if the OpenSSH client is installed by displaying its version. ```bash ssh -V ``` -------------------------------- ### Initialize OpenAI Client Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/foundations/tools.md Setup the OpenAI client with the base URL and API key. ```js import { OpenAI } from "openai"; const openai = new OpenAI({ baseURL: 'https://docs.liara.ir/baseUrl', apiKey: '', }); ``` -------------------------------- ### Example Dockerfile for Go Application Source: https://github.com/liara-cloud/docs/blob/master/src/pages/paas/docker/quick-start.mdx A sample Dockerfile configuration for a Go-based application. ```docker # Set the working directory inside the container WORKDIR /app # Copy the local code to the container COPY . . # Download Go modules RUN go mod download # Build the Go application RUN go build -o main . # Expose port 8080 to the outside world # EXPOSE 8080 # Command to run the executable CMD ["./main"] ``` ```docker # Use the official go image as the base image FROM go:latest ``` -------------------------------- ### Install Go OpenAI Library Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/foundations/prompts.md Command to install the required Go dependency. ```bash go get github.com/sashabaranov/go-openai ``` -------------------------------- ### Install OpenAI SDK for Go Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/aionlabs.md Install the required OpenAI Go packages. ```bash go get package github.com/openai/openai-go go get package github.com/openai/openai-go/option ``` -------------------------------- ### Complete liara.json Configuration Example Source: https://github.com/liara-cloud/docs/blob/master/public/llms/paas/docker/how-tos/deploy-app.md A comprehensive example showing multiple configuration fields including app name, port, build settings, and environment arguments. ```json { "app": "my--app", "port": 8080, "platform": "docker", "build": { "dockerfile": "./Dockerfile", "cache": false, "args": ["APP_VERSION=2.0.0"] }, "docker": { "timezone": "America/Los_Angeles" }, "args": [ "sh", "-c", "sleep 10 && /entrypoint.sh run" ] } ``` -------------------------------- ### Install OpenAI SDK for Python Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/aionlabs.md Install the official OpenAI Python package. ```bash pip install openai ``` -------------------------------- ### Install Go dependencies Source: https://github.com/liara-cloud/docs/blob/master/public/llms/dbaas/mariadb/how-tos/connect-via-platform/go.md Install the MySQL driver and the godotenv package to manage environment variables. ```bash go get -u github.com/go-sql-driver/mysql go get github.com/joho/godotenv ``` -------------------------------- ### liara db start Source: https://github.com/liara-cloud/docs/blob/master/public/llms/references/cli/start-db.md Starts a database instance using the Liara CLI. ```APIDOC ## liara db start ### Description Starts a database instance in the Liara cloud environment. ### Usage `liara db start [-h] [--debug] [--api-token ] [--account ] [-n ] [--team-id ]` ### Parameters - **-h** (flag) - Optional - Show help for the command. - **--debug** (flag) - Optional - Enable debug mode. - **--api-token** (string) - Optional - Specify the API token for authentication. - **--account** (string) - Optional - Specify the account identifier. - **-n** (string) - Optional - Specify the database name. - **--team-id** (string) - Optional - Specify the team identifier. ``` -------------------------------- ### Initialize OpenAI Client in Go Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/foundations/tools.md Sets up the OpenAI client with API key and base URL for Go applications. ```go client := openai.NewClient( option.WithAPIKey(""), option.WithBaseURL(""), ) ``` -------------------------------- ### Complete liara.json Example Source: https://github.com/liara-cloud/docs/blob/master/src/pages/paas/docker/how-tos/deploy-app.mdx A comprehensive example combining application settings, build configurations, and Docker-specific options. ```json { "app": "my--app", "port": 8080, "platform": "docker", "build": { "dockerfile": "./Dockerfile", "cache": false, "args": ["APP_VERSION=2.0.0"] }, "docker": { "timezone": "America/Los_Angeles" } } ``` -------------------------------- ### Weather Output Example Source: https://github.com/liara-cloud/docs/blob/master/public/llms/ai/foundations/tools.md Example console output for a successful weather query. ```bash The weather in Tehran is 35° celsius, Sunny. ```