first test
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
21132b33d4
commit
6fe1818ec9
75
flake.lock
generated
75
flake.lock
generated
@ -1,6 +1,40 @@
|
||||
{
|
||||
"nodes": {
|
||||
"iosevka": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1679684486,
|
||||
"narHash": "sha256-XMpeeKmzxYpkh8uuxyGHcYzgORVysC8vMIVbzQdPtTs=",
|
||||
"owner": "Xe",
|
||||
"repo": "iosevka",
|
||||
"rev": "85a6850cf67884b2d4752442bb9246415681e9e9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Xe",
|
||||
"repo": "iosevka",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1678898370,
|
||||
"narHash": "sha256-xTICr1j+uat5hk9FyuPOFGxpWHdJRibwZC+ATi0RbtE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ac718d02867a84b42522a0ece52d841188208f2c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681217261,
|
||||
"narHash": "sha256-RbxCHWN3Vhyv/WEsXcJlDwF7bpvZ9NxDjfSouQxXEKo=",
|
||||
@ -17,8 +51,10 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
"iosevka": "iosevka",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"typst": "typst",
|
||||
"utils": "utils_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
@ -36,7 +72,42 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"typst": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681296471,
|
||||
"narHash": "sha256-437YmGedi3S8GT7WOQTgruQEl/+QqB/8mOuGpJphjYg=",
|
||||
"owner": "typst",
|
||||
"repo": "typst",
|
||||
"rev": "1198e0cd385737efc38dbd8ba13db802a68e0dc7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "typst",
|
||||
"repo": "typst",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1678901627,
|
||||
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
|
48
flake.nix
48
flake.nix
@ -2,17 +2,51 @@
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
|
||||
# Explicitly pulling from that version of nixpkgs to avoid font duplication.
|
||||
iosevka.url = "github:Xe/iosevka";
|
||||
|
||||
typst.url = "github:typst/typst";
|
||||
typst.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils }:
|
||||
outputs = { self, nixpkgs, utils, typst, iosevka }:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system}; in
|
||||
{
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ typst.overlays.default ];
|
||||
};
|
||||
typstWithIosevka = let
|
||||
fontsConf = pkgs.symlinkJoin {
|
||||
name = "typst-fonts";
|
||||
paths =
|
||||
[ "${self.packages.${system}.iosevka}" ];
|
||||
};
|
||||
in pkgs.writeShellApplication {
|
||||
name = "typst";
|
||||
text = ''
|
||||
${pkgs.typst-dev}/bin/typst \
|
||||
--font-path ${fontsConf} \
|
||||
"$@"
|
||||
'';
|
||||
runtimeInputs = [ ];
|
||||
};
|
||||
in {
|
||||
packages.iosevka = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "iosevka-iaso-ttf";
|
||||
buildInputs = with pkgs; [ unzip ];
|
||||
dontUnpack = true;
|
||||
buildPhase = ''
|
||||
unzip ${self.inputs.iosevka.packages.${system}.default}/ttf.zip
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp ttf/* $out
|
||||
'';
|
||||
};
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
nodejs-18_x
|
||||
pandoc
|
||||
];
|
||||
buildInputs = with pkgs; [ nodejs-18_x pandoc typstWithIosevka ];
|
||||
shellHook = ''
|
||||
export PATH="$PATH":$(pwd)/node_modules/.bin
|
||||
'';
|
||||
|
11
index.ts
11
index.ts
@ -1,8 +1,12 @@
|
||||
import * as dotenv from "dotenv";
|
||||
import { Configuration, OpenAIApi } from "openai";
|
||||
import PlotGenerator from "@xeserv/plottoriffic";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const pg = new PlotGenerator({});
|
||||
const plot = pg.generate();
|
||||
|
||||
const configuration = new Configuration({
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
});
|
||||
@ -10,6 +14,11 @@ const openai = new OpenAIApi(configuration);
|
||||
|
||||
const completion = await openai.createChatCompletion({
|
||||
model: "gpt-3.5-turbo",
|
||||
messages: [{ role: "user", content: "Hello world" }],
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: "Write me a plot summary for the following story:\n\n" + plot.plot,
|
||||
},
|
||||
],
|
||||
});
|
||||
console.log(completion.data.choices[0].message);
|
||||
|
24
types/plottoriffic.d.ts
vendored
Normal file
24
types/plottoriffic.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
declare module "@xeserv/plottoriffic" {
|
||||
export default PlotGenerator;
|
||||
|
||||
export type Character = {
|
||||
symbol: string;
|
||||
name: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
export type Plot = {
|
||||
subject: string;
|
||||
group: string;
|
||||
subgroup: string;
|
||||
description: string;
|
||||
cast: Character[];
|
||||
plot: string;
|
||||
};
|
||||
|
||||
export class PlotGenerator {
|
||||
constructor({ flipGenders }: { flipGenders?: boolean });
|
||||
|
||||
generate(): Plot;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user