// Some copyright should be here...
using UnrealBuildTool;
public class furcraHomeAIServerChat2 : ModuleRules
{
public furcraHomeAIServerChat2(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core", "CoreUObject", "Engine", "UMG","HTTP", "Json", "JsonUtilities"
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"DeveloperSettings",
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}
// Fill out your copyright notice in the Description page of Project Settings.
#include "AiChatTypes.h"
AiChatTypes::AiChatTypes()
{
}
AiChatTypes::~AiChatTypes()
{
}
AiLinkAsyncChat.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "AiChatTypes.h"
#include "AiLinkAsyncChat.generated.h"
// Forward declarations for HTTP interfaces to avoid including HTTP headers in this public header
class IHttpRequest;
class IHttpResponse;
using FHttpRequestPtr = TSharedPtr<IHttpRequest, ESPMode::ThreadSafe>;
using FHttpResponsePtr = TSharedPtr<IHttpResponse, ESPMode::ThreadSafe>;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FAiChatSuccess, const FString&, AssistantText);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FAiChatError, const FString&, Error);
UCLASS()
class FURCRAHOMEAISERVERCHAT2_API UAiLinkAsyncChat : public UBlueprintAsyncActionBase
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintAssignable) FAiChatSuccess OnSuccess;
UPROPERTY(BlueprintAssignable) FAiChatError OnError;
// Messagesは「system + 履歴 + 今回のuser」を含めて渡す
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"))
static UAiLinkAsyncChat* SendChat(const TArray<FAiChatMessage>& Messages);
virtual void Activate() override;
private:
TArray<FAiChatMessage> MessagesInternal;
void HandleResponse(FHttpRequestPtr Req, FHttpResponsePtr Resp, bool bOk);
};
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
/**
*
*/
class FURCRAHOMEAISERVERCHAT2_API AiLinkRequestTypes
{
public:
AiLinkRequestTypes();
~AiLinkRequestTypes();
};
//#pragma once
//#include "CoreMinimal.h"
#include "AiLinkRequestTypes.generated.h"
USTRUCT()
struct FOllamaGenerateRequest
{
GENERATED_BODY()
UPROPERTY() FString model;
UPROPERTY() FString prompt;
UPROPERTY() bool stream = false;
};
USTRUCT()
struct FOllamaGenerateResponse
{
GENERATED_BODY()
UPROPERTY() FString response;
UPROPERTY() bool done = false;
};
AiLinkRequestTypes.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "AiLinkRequestTypes.h"
AiLinkRequestTypes::AiLinkRequestTypes()
{
}
AiLinkRequestTypes::~AiLinkRequestTypes()
{
}
UAiLinkSettings.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DeveloperSettings.h"
#include "UAiLinkSettings.generated.h"
UCLASS(Config = Game, DefaultConfig, meta = (DisplayName = "Home AI Chat"))
class FURCRAHOMEAISERVERCHAT2_API UAiLinkSettings : public UDeveloperSettings
{
GENERATED_BODY()
public:
UPROPERTY(Config, EditAnywhere, Category = "AI")
FString BaseUrl = TEXT("http://192.168.1.23:11434");
UPROPERTY(Config, EditAnywhere, Category = "AI")
//FString Model = TEXT("llama3.1");
//FString Model = TEXT("deepseek-r1:32b");llama3.1:8b
//FString Model = TEXT("llama3.1:70b");//llama3.1:8b
FString Model = TEXT("llama3.1:8b");//
UPROPERTY(Config, EditAnywhere, Category = "AI")
float TimeoutSeconds = 120.0f;
// 例: "You are NPC assistant in my game..."
UPROPERTY(Config, EditAnywhere, Category = "AI")
FString SystemPrompt = TEXT("You are a helpful in-game NPC. Keep replies concise.");
};
UAiLinkSettings.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "UAiLinkSettings.h"
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Modules/ModuleManager.h"
class FfurcraeaBluePrintLibModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};
furcraeaBluePrintLib.cpp
// Copyright Epic Games, Inc. All Rights Reserved.
#include "furcraeaBluePrintLib.h"
#define LOCTEXT_NAMESPACE "FfurcraeaBluePrintLibModule"
void FfurcraeaBluePrintLibModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
}
void FfurcraeaBluePrintLibModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FfurcraeaBluePrintLibModule, furcraeaBluePrintLib)
furcraeaBluePrintLibBPLibrary.h
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "furcraeaBluePrintLibBPLibrary.generated.h"
/*
* Function library class.
* Each function in it is expected to be static and represents blueprint node that can be called in any blueprint.
*
* When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable.
* BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins.
* BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins.
* DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu.
* Its lets you name the node using characters not allowed in C++ function names.
* CompactNodeTitle - the word(s) that appear on the node.
* Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu.
* Good example is "Print String" node which you can find also by using keyword "log".
* Category - the category your node will be under in the Blueprint drop-down menu.
*
* For more info on custom blueprint nodes visit documentation:
* https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation
*/
UCLASS()
class UfurcraeaBluePrintLibBPLibrary : public UBlueprintFunctionLibrary
{
GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Execute Sample function", Keywords = "furcraeaBluePrintLib sample test testing"), Category = "furcraeaBluePrintLibTesting")
static float furcraeaBluePrintLibSampleFunction(float Param);
};
furcraeaBluePrintLibBPLibrary.cpp
// Copyright Epic Games, Inc. All Rights Reserved.
#include "furcraeaBluePrintLibBPLibrary.h"
#include "furcraeaBluePrintLib.h"
UfurcraeaBluePrintLibBPLibrary::UfurcraeaBluePrintLibBPLibrary(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
float UfurcraeaBluePrintLibBPLibrary::furcraeaBluePrintLibSampleFunction(float Param)
{
return -1;
}