Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions .github/workflows/ci-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Beta-tier proxy, BHoM variant. Bundles the tier's checks plus
# copyright-compliance (BHoM enforces OSS copyright; the BHE variant omits it).
# Copy to .github/workflows/ci-beta.yml in each BHoM beta repo.
# Runs on pull_request, non-blocking until a ruleset requires its checks.
# Workflow name CI keeps check contexts bare: required contexts are the job names.

name: CI

on:
pull_request:
branches:
- develop

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
ci-build:
runs-on: windows-2025-vs2026
timeout-minutes: 30
steps:
- name: Run build
uses: BHoM/CI_Toolkit/.github/actions/ci-build@develop
with:
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}

ci-code-compliance:
runs-on: windows-2025-vs2026
timeout-minutes: 20
permissions:
contents: read
pull-requests: read
actions: write
steps:
- name: Run code compliance
uses: BHoM/CI_Toolkit/.github/actions/ci-compliance@develop
with:
check_type: code
patterns: '*.cs'
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}

ci-copyright-compliance:
runs-on: windows-2025-vs2026
timeout-minutes: 20
permissions:
contents: read
pull-requests: read
actions: write
steps:
- name: Run copyright compliance
uses: BHoM/CI_Toolkit/.github/actions/ci-compliance@develop
with:
check_type: copyright
patterns: '*.cs'
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}

ci-dataset-compliance:
runs-on: windows-2025-vs2026
timeout-minutes: 20
permissions:
contents: read
pull-requests: read
actions: write
steps:
- name: Run dataset compliance
uses: BHoM/CI_Toolkit/.github/actions/ci-compliance@develop
with:
check_type: dataset
patterns: ':(icase)*datasets*.json'
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}

ci-documentation-compliance:
runs-on: windows-2025-vs2026
timeout-minutes: 20
permissions:
contents: read
pull-requests: read
actions: write
steps:
- name: Run documentation compliance
uses: BHoM/CI_Toolkit/.github/actions/ci-compliance@develop
with:
check_type: documentation
patterns: '*.cs'
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}

ci-project-compliance:
runs-on: windows-2025-vs2026
timeout-minutes: 20
permissions:
contents: read
pull-requests: read
actions: write
steps:
- name: Run project compliance
uses: BHoM/CI_Toolkit/.github/actions/ci-compliance@develop
with:
check_type: project
patterns: '*AssemblyInfo.cs *.csproj'
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}

ci-dataset-tests:
runs-on: windows-2025-vs2026
timeout-minutes: 30
steps:
- name: Run dataset tests
uses: BHoM/CI_Toolkit/.github/actions/ci-dataset-tests@develop
with:
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}

ci-serialisation:
runs-on: windows-2025-vs2026
timeout-minutes: 90
steps:
- name: Run serialisation
uses: BHoM/CI_Toolkit/.github/actions/ci-serialisation@develop
with:
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}
base_ref: ${{ github.base_ref }}

ci-versioning:
runs-on: windows-2025-vs2026
timeout-minutes: 90
steps:
- name: Run versioning
uses: BHoM/CI_Toolkit/.github/actions/ci-versioning@develop
with:
app_id: ${{ secrets.BHOM_APP_ID }}
private_key: ${{ secrets.BHOM_APP_PRIVATE_KEY }}
61 changes: 55 additions & 6 deletions OpenAI_Adapter/AdapterActions/Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using BH.oM.Adapter;
using BH.oM.Adapters.OpenAI;
using BH.oM.Adapters.OpenAI.Commands;
using BH.oM.Adapters.OpenAI.Output;
using BH.oM.Base;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -110,13 +111,29 @@ private async Task<string> PromptAsync(string system, IEnumerable<string> user,
messages.AddRange(user.Select(x => new { role = "user", content = x }));
messages.AddRange(assistant.Select(x => new { role = "assistant", content = x }));

var requestBody = new
object responseFormat = BuildResponseFormat(config.OutputType);
object requestBody;
if (responseFormat == null)
{
messages = messages,
max_tokens = config.MaxTokens,
temperature = config.Temperature,
top_p = config.TopP
};
requestBody = new
{
messages = messages,
max_tokens = config.MaxTokens,
temperature = config.Temperature,
top_p = config.TopP
};
}
else
{
requestBody = new
{
messages = messages,
max_tokens = config.MaxTokens,
temperature = config.Temperature,
top_p = config.TopP,
response_format = responseFormat
};
}

string json = JsonSerializer.Serialize(requestBody);
StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
Expand All @@ -138,6 +155,38 @@ private async Task<string> PromptAsync(string system, IEnumerable<string> user,
}

/***************************************************/

private static object BuildResponseFormat(IOutputType outputType)
{
if (outputType == null || outputType is Text)
return null;

if (outputType is JsonObject)
return new { type = "json_object" };

if (outputType is JsonSchema jsonSchema)
{
if (string.IsNullOrWhiteSpace(jsonSchema.Schema))
return null;

string schemaName = string.IsNullOrWhiteSpace(jsonSchema.Name) ? "structured_output" : jsonSchema.Name;

return new
{
type = "json_schema",
json_schema = new
{
strict = true,
name = schemaName,
schema = JsonSerializer.Deserialize<JsonElement>(jsonSchema.Schema),
}
};
}

return null;
}

/***************************************************/
}
}

130 changes: 65 additions & 65 deletions OpenAI_Adapter/OpenAI_Adapter.csproj
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/OpenAI_Toolkit</Description>
<Version>8.0.0</Version>
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Adapter.OpenAI</RootNamespace>
<FileVersion>9.2.0.0</FileVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<OutputPath>..\Build\</OutputPath>
</PropertyGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;$(ProgramData)\BHoM\Assemblies&quot; /Y&#xD;&#xA;xcopy &quot;$(TargetDir)System.Text.Json.dll&quot; &quot;$(ProgramData)\BHoM\Assemblies&quot; /Y&#xD;&#xA;xcopy &quot;$(TargetDir)System.Text.Encodings.Web.dll&quot; &quot;$(ProgramData)\BHoM\Assemblies&quot; /Y" />
</Target>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OpenAI_Engine\OpenAI_Engine.csproj" />
<ProjectReference Include="..\OpenAI_oM\OpenAI_oM.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="BHoM">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="Data_oM">
<HintPath>$(ProgramData)\BHoM\Assemblies\Data_oM.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="Adapter_oM">
<HintPath>$(ProgramData)\BHoM\Assemblies\Adapter_oM.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="Adapter_Engine">
<HintPath>$(ProgramData)\BHoM\Assemblies\Adapter_Engine.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="BHoM_Adapter">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM_Adapter.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="BHoM_Engine">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<Description>https://github.com/BHoM/OpenAI_Toolkit</Description>
<Version>8.0.0</Version>
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Adapter.OpenAI</RootNamespace>
<FileVersion>9.3.0.0</FileVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<OutputPath>..\Build\</OutputPath>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;$(ProgramData)\BHoM\Assemblies&quot; /Y&#xD;&#xA;xcopy &quot;$(TargetDir)System.Text.Json.dll&quot; &quot;$(ProgramData)\BHoM\Assemblies&quot; /Y&#xD;&#xA;xcopy &quot;$(TargetDir)System.Text.Encodings.Web.dll&quot; &quot;$(ProgramData)\BHoM\Assemblies&quot; /Y" />
</Target>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenAI_Engine\OpenAI_Engine.csproj" />
<ProjectReference Include="..\OpenAI_oM\OpenAI_oM.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="BHoM">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="Data_oM">
<HintPath>$(ProgramData)\BHoM\Assemblies\Data_oM.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="Adapter_oM">
<HintPath>$(ProgramData)\BHoM\Assemblies\Adapter_oM.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="Adapter_Engine">
<HintPath>$(ProgramData)\BHoM\Assemblies\Adapter_Engine.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="BHoM_Adapter">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM_Adapter.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
<Reference Include="BHoM_Engine">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
<Private>false</Private>
<SpecificVersion>false</SpecificVersion>
</Reference>
</ItemGroup>
</Project>
Loading