我们有一个 ChatGPT 的用例,用于总结长文本(语音到文本的对话可能超过一个小时)。
然而,我们发现 4k 令牌限制往往会导致输入文本由于令牌限制而被截断为一半左右。
零件加工似乎没有保留以前零件的历史。
对于提交超过 4k 代币的较长请求,我们有哪些选项?
当我没有实例时,我经常想要获取类型的实例属性的名称.目前要执行此操作,我使用以下内部函数来解释Expression[Func[T, object]]参数并返回属性名称:
var str = LinqExtensions.NameOf<ClientService>(x => x.EndDate);
// Now str == "EndDate"
Run Code Online (Sandbox Code Playgroud)
然而,不使用内置nameof运算符似乎是一种耻辱.
不幸的是,nameof运算符似乎需要一个实例,或者引用一个静态属性.
是否有一种巧妙的方式来使用nameof操作员而不是我们的内部功能?例如:
nameof(ClientService.EndDate) // ClientService.EndDate not normally syntactically valid as EndDate is instance member
Run Code Online (Sandbox Code Playgroud)
编辑
我完全错了,nameof(ClientService.EndDate)所描述的语法实际上是按原样工作的.
C#具有高性能阵列复印功能来复制阵列到位:
Array.Copy(source, destination, length)
Run Code Online (Sandbox Code Playgroud)
它比手动操作更快,即:
for (var i = 0; i < length; i++)
destination[i] = source[i];
Run Code Online (Sandbox Code Playgroud)
我在寻找一个相当于高性能复制功能来复制阵列到位在Javascript中,用于Int32Array和Float32Array能及时发现没有这样的功能:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
最接近的是"copyWithin",它只在数组内部进行复制.
是否有一个内置的高性能拷贝功能TypedArrays 到位?
B计划,是否有内置的高性能克隆功能?(编辑:看起来像slice()就是答案)
我想通过将DbCompiledModel缓存到磁盘来减少EF6中的启动时间.
为DbContext编写EDMX文件很容易:
EdmxWriter.WriteEdmx(myDbContext, XmlWriter.Create(@"C:\temp\blah.xml"))
Run Code Online (Sandbox Code Playgroud)
并且很容易将DbCompiledModel传递给DbContext:
var db = new DbContext(connectionString, myDbCompiledModel)
Run Code Online (Sandbox Code Playgroud)
但是,似乎没有任何方法可以将EDMX文件从磁盘读入DbCompiledModel!我怎样才能做到这一点?
请注意,我已在此分支版本的EF6中使用EdmxReader工具成功实施了该解决方案:
https://github.com/davidroth/entityframework/tree/DbModelStore
Run Code Online (Sandbox Code Playgroud)
但是,我不愿意在生产环境中使用分支版本.我试过从这个分支中提取EdmxReader实用程序,但它依赖于我无法访问的DbCompiledModel的内部构造函数.
那么,我如何从磁盘获取EDMX文件并将其转换为DbCompiledModel?
在DDD中为新实体设置默认属性的最佳方法是什么?另外,为复杂属性(例如集合)设置默认状态的最佳方法是什么?
我的感觉是默认值应该在模型本身,因为它们是业务规则的一种形式("默认情况下,我们希望X是Y&Z"),域代表业务.使用这种方法,可能模型本身的静态"GetNew()"方法可以工作:
public class Person {
public string Name { get; set; }
public DateTime DateOfBirth { get; set; }
public bool IsAlive { get; set; }
public List Limbs { get; set; }
public static Person GetNew() {
return new Person() {
IsAlive = true,
Limbs = new List() { RightArm, LeftArm, RightLeg, LeftLeg }
}
}
}
不幸的是,在我们的例子中,我们需要将collection属性设置为另一个列表的所有成员,并且由于此模型与其Repository/DbContext分离,因此它没有任何方法可以将它们全部加载.
Crappy解决方案将作为参数传递:
public static Person GetNew(List<Limb> allLimbs) {
return new Person() {
IsAlive = true,
Limbs = allLimbs
}
}
Run Code Online (Sandbox Code Playgroud)
或者,是否有一些更好的方法来设置简单和复杂模型属性的默认值?
我有以下实例:
Expression<Func<IRequiredDate, bool>>
Run Code Online (Sandbox Code Playgroud)
我希望将其转换为以下实例,因此它可用于在Entity Framework中运行查询:
Expression<Func<TModel, bool>>
Run Code Online (Sandbox Code Playgroud)
这将允许我对任何实现IRequiredDate的Model使用通用过滤查询,例如:
// In some repository function:
var query = DbContext.Set<Order>()
.FilterByDateRange(DateTime.Today, DateTime.Today);
var query = DbContext.Set<Note>()
.FilterByDateRange(DateTime.Today, DateTime.Today);
var query = DbContext.Set<Complaint>()
.FilterByDateRange(DateTime.Today, DateTime.Today);
// The general purpose function, can filter for any model implementing IRequiredDate
public static IQueryable<TModel> FilterByDate<TModel>(IQueryable<TModel> query, DateTime startDate, DateTime endDate) where TModel : IRequiredDate
{
// This will NOT WORK, as E/F won't accept an expression of type IRequiredDate, even though TModel implements IRequiredDate
// Expression<Func<IRequiredDate, bool>> dateRangeFilter …Run Code Online (Sandbox Code Playgroud) 我们在 Windows 2008 Server 上运行 Postgres 9.0。有一个大表包含一bytea列,用于存储每行 0-5MB 的二进制数据:
CREATE TABLE files
(
file_id serial NOT NULL,
data bytea NOT NULL,
on_disk boolean,
CONSTRAINT files_pkey PRIMARY KEY (file_id)
)
Run Code Online (Sandbox Code Playgroud)
最近我们一直在更新每一行的 on_disk 字段(不涉及数据字段)。我们认为这已经占用了我们临时表空间(或其他东西)中的空间,原因有两个:
1) 我们开始在运行大型查询的系统的其他随机部分收到此错误:
ERROR: 53100: could not write block 92271 of temporary file
Run Code Online (Sandbox Code Playgroud)
2) 我们的可用空间在一周内从 ~7GB 下降到 1.5GB,这是不寻常的。
任何人都可以确认:
a) 在 postgres 中更新一行是否会导致它在不释放旧空间的情况下重写整个行(包括大型二进制数据)?这将解释我们的症状
b) 它是否在更改期间写入其他临时表空间,这也会占用空间?(我们可以强制释放临时空间吗?)
c) 有没有一种方法可以对这个表执行次要的布尔字段更新,而无需每次都重写行(&咀嚼磁盘空间)?
d) 我们可以在不重写整个表的情况下定期强制 postgres 释放已用空间吗?(我们已知的释放空间的方法涉及我们没有空间的表重写)
PS:是的,我们正在将我们的服务器迁移到具有更大存储空间的主机......这可能需要 1-2 个月的时间。
我们有一个C#winforms应用程序,它使用大量对象实例,float []数组和对象引用来模拟3D地球和世界状态,以表示世界状态和对象之间的关系.
我们被要求将此软件迁移到Web并在Javascript中重新实现它.
据我所知,C#可以使用本机代码,但听起来好像近年来Javascript性能也取得了巨大进步.
我想知道对于.NET或其他以原生性能执行的语言,对于对象和数组的原始数据操作,是否有任何关于Javascript票价,性能和内存的一般信息或比较?
我已经定义了这些方法重载,只有Action/Func参数不同:
public void DoSomethingWithValues(Action<decimal, decimal> d, decimal x, decimal y)
{
d(x, y);
}
public void DoSomethingWithValues(Func<decimal, decimal, decimal> d, decimal x, decimal y)
{
var value = d(x, y);
}
Run Code Online (Sandbox Code Playgroud)
我尝试通过内联lambda,Func <>和方法调用它们:
public Func<decimal, decimal, decimal> ImAFuncWhichDoesSomething = (x, y) => (x + y) / 5;
public decimal ImAMethodWhichDoesSomething(decimal x, decimal y)
{
return (x + y + 17) / 12;
}
public void DoSomething()
{
DoSomethingWithValues((x, y) => (x - y) / 17 , 1, 2); // Inline …Run Code Online (Sandbox Code Playgroud) 我使用MVC文件夹结构,其中URL路由恰好与目录名称匹配,例如:
<proj>\My\Cool\Thing\ThingController.cs
Run Code Online (Sandbox Code Playgroud)
需要通过以下网址访问:
http://blahblah/My/Cool/Thing
Run Code Online (Sandbox Code Playgroud)
我可以使用MVC路由,但是不幸的是,当依靠默认的{action}和{id}时,IIS Express会将请求路由到DirectoryListingModule,因为它直接与文件夹名称匹配。目录列表当然是禁用的,所以我得到了:
The Web server is configured to not list the contents of this directory.
Module DirectoryListingModule
Notification ExecuteRequestHandler
Handler StaticFile
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我已经尝试过:
1. runAllManagedModulesForAllRequests = true
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" >
//Makes no difference
2. Removing module
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" >
<remove name="DirectoryListingModule"/>
// Won't let me as module is locked in IIS
</modules>
</system.webServer>
3. Removing lock & module
// applicationhost.config
<add name="DirectoryListingModule" lockItem="false" />
// web.config
<remove name="DirectoryListingModule"/>
// Causes startup error"Handler "StaticFile" has a …Run Code Online (Sandbox Code Playgroud) c# ×4
javascript ×2
performance ×2
asp.net-mvc ×1
c#-6.0 ×1
chatgpt-api ×1
default ×1
delegates ×1
diskspace ×1
edmx ×1
expression ×1
httpmodule ×1
iis-7 ×1
lambda ×1
linq ×1
models ×1
nameof ×1
openai-api ×1
overloading ×1
postgresql ×1
sql ×1
typedarray ×1
windows ×1